简体   繁体   English

我的 Django 帐户应用程序出现错误

[英]I have an error in my Django accounts app

I was following the tutorial on https://simpleisbetterthancomplex.com/series/2017/09/25/a-complete-beginners-guide-to-django-part-4.html and I have an error message which says that account_views is not defined.我正在关注https://simpleisbetterthancomplex.com/series/2017/09/25/a-complete-beginners-guide-to-django-part-4.html的教程,我收到一条错误消息,上面写着 account_view没有定义的。 In my urls.py file which is located in C:\Users\vitorfs\Development\myproject\myproject\myproject.在我位于 C:\Users\vitorfs\Development\myproject\myproject\myproject 的 urls.py 文件中。 Here is the code这是代码

from django.conf.urls import url
from django.contrib import admin

from accounts import views as account_views
from boards import views


urlpatterns = [
    url(r'^$', views.home, name='home'),
    url(r'^signup/$', accounts_views.signup, name='signup'),
    url(r'^boards/(?P<pk>\d+)/$', views.board_topics, name='board_topics'),
    url(r'^boards/(?P<pk>\d+)/new/$', views.new_topic, name='new_topic'),
    url(r'^admin/', admin.site.urls),
]

The error is on line 25, url(r'^signup/$', accounts_views.signup, name='signup'), which states that account_views is not defined.错误在第 25 行,url(r'^signup/$', accounts_views.signup, name='signup'),它指出 account_views 没有定义。 I would like to know why I am getting this error, and also, can you show me how to fix this error?我想知道为什么我会收到这个错误,还有,你能告诉我如何解决这个错误吗?

When you are importing the accounts in the top of the file, you are saying from accounts import views as account_views .当您在文件顶部导入帐户时,您是说from accounts import views as account_views You are importing it as account_views so in your urls, you should say account_views not accounts_views.您将其作为account_views导入,因此在您的 url 中,您应该说 account_views 而不是 accounts_views。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我是否正确组织了我的django应用程序? - Have I organised my django app correctly? 我有一个在django应用程序上本地运行的功能,但部署该功能会导致列表索引超出范围错误 - I have afunction that works locally on my django app but deployed it raises an list index out of range error Django LookupError:应用程序“帐户”没有“用户”模型 - Django LookupError: App 'accounts' doesn't have a 'User' model 无法登录我在Django中创建的用户帐户 - Unable to login user accounts I have created in django 我无法为 Heroku 配置我的 Django 应用程序 - I am have trouble configuring my Django app for Heroku 我在应用引擎中的 Django 应用中收到错误 404 - I get an Error 404 in my Django App in app engine 在 django-python 中迁移我的数据库时出错 - I have error when migrating my db in django-python 为什么我在 django 上的 html 文件中出现 endfor 加载错误? - Why I have a loading error for endfor on my html file on django? Django:每次我开发 django 应用程序时都必须打开虚拟环境吗 - Django: Does the virtual environment have to be on every time i develop my django app Django 应用程序:运行服务器时出现“未找到 URL”错误 - Django app : "URL not found" error when i run my server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM