我在 Django 中进行登录和注册,但出现以下错误。请帮我解决它。
文件“/home/mritunjay/project/pr/fitbit/accounts/urls.py”,第 7 行,在路径('',views.home,name =“home”)中,NameError:名称'views'未定义
这里urls.py (app)
from django.urls import path
from accounts.views import home, SignUpView
app_name = "accounts"
urlpatterns = [
path('', views.home, name="home"),
path('signup/', SignUpView.as_view(), name='signup'),
path('login/', views.login, name='login'),
]
这里views.py (app)
from django.shortcuts import render
from django.urls import reverse_lazy
from django.views.generic import CreateView
from accounts.forms import SignUpForm
from django.contrib.auth.models import User
class SignUpView(CreateView):
success_url = reverse_lazy('login')
template_name = 'templates/signup.html'
def home(request):
return render(request, "home.html", {})
这里是urls.py(项目)
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView
#from accounts import urls
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('accounts.urls')),
# Main Page
path('', TemplateView.as_view(template_name='home.html'), name='home'),
# Login and Logout
path('login/', auth_views.LoginView.as_view(redirect_authenticated_user=True, template_name='templates/login.html'), name='login'),
path('logout/', auth_views.LogoutView.as_view(next_page='home'), name='logout'),
]
这些是 **NameError: name 'views' is not defined ** 显示在urls.py(app)中的代码
请帮助我。
慕尼黑的夜晚无繁华
相关分类