[英]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.