Answer the question
In order to leave comments, you need to log in
How to fix 'function' object has no attribute 'as_view' error?
I'm making an authorization system on Django 4.0.3.
from django.http import HttpResponse, Http404
from django.template import TemplateDoesNotExist
from django.template.loader import get_template
from django.shortcuts import render
from django.contrib.auth.views import LoginView, LogoutView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.decorators import login_required
def MyLoginView(LoginView):
template_name = 'main/login.html'
def MyLogoutView(LoginRequiredMixin,LogoutView):
template_name = 'main/logout.html'
...
from django.urls import path
from .views import index, other_page, MyLoginView, MyLogoutView, profile
app_name='main'
urlpatterns = [
path('accounts/login/', MyLoginView.as_view(), name='login'),
path('accounts/logout/', MyLogoutView.as_view(), name='logout'),
....
]
File "./bboard/main/urls.py", line 7, in
path('accounts/login/', MyLoginView.as_view(), name='login'),
AttributeError: 'function' object has no attribute 'as_view '
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question