无法找到上述错误的来源:我已经审查了下面的链接,提供的解决方案没有解决我的问题:Django -循环模型导入问题 以下url似乎会导致出现循环导入错误。当注释掉时,错误不会出现。 simplesocial / urls . py
urlpatterns = [
url(r"^$", views.HomePage.as_view(), name="home"),
url(r"^test/$", views.TestPage.as_view(), name="test"),
url(r"^thanks/$", views.ThanksPage.as_view(), name="thanks"),
url(r"^admin/", admin.site.urls),
url(r"^accounts/", include("accounts.urls", namespace="accounts")), #causes circular
reference
url(r"^accounts/", include("django.contrib.auth.urls")), # causes circular reference
url(r"^posts/", include("posts.urls", namespace="posts")), # causes circular reference
url(r"^groups/",include("groups.urls",namespace="groups")),
账户/ urls . py
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from . import views
app_name = 'accounts'
urlpatterns = [
url(r"^$", views.LoginView.as_view(), name="login"), #works, review
#url(r"^login/$",accounts.views.LoginView,name="login"),#additional url pattern. test.
#url(r"^$", views.LoginView.as_view(template_name="accounts/login.html"), name="login"),#test. does this work??
url(r"login/$", auth_views.LoginView.as_view(template_name="accounts/login.html")),
url(r"logout/$", auth_views.LogoutView.as_view(), name="logout"),
url(r"signup/$", views.SignUp.as_view(), name="signup"),
]
组/ urls . py
from django.conf.urls import url
from . import views
app_name = 'groups'
urlpatterns = [
url(r"^$", views.ListGroups.as_view(), name="all"),
url(r"^new/$", views.CreateGroup.as_view(), name="create"),
url(r"^posts/in/(?P<slug>[-\w]+)/$",views.SingleGroup.as_view(),name="single"),
url(r"join/(?P<slug>[-\w]+)/$",views.JoinGroup.as_view(),name="join"),
url(r"leave/(?P<slug>[-\w]+)/$",views.LeaveGroup.as_view(),name="leave"),
]
职位/ urls . py
from django.conf.urls import url
from . import views
app_name='posts'
urlpatterns = [
url(r"^$", views.PostList.as_view(), name="all"),
url(r"new/$", views.CreatePost.as_view(), name="create"),
url(r"by/(?P<username>[-\w]+)/$",views.UserPosts.as_view(),name="for_user"),
url(r"by/(?P<username>[-\w]+)/(?P<pk>\d+)/$",views.PostDetail.as_view(),name="single"),
url(r"delete/(?P<pk>\d+)/$",views.DeletePost.as_view(),name="delete"),
]
但是,在注释simplesocial/url .py文件中的以下3行代码时。 返回以下错误: NoReverseMatch在/ “accounts”不是注册的名称空间
urlpatterns = [
url(r"^$", views.HomePage.as_view(), name="home"),
url(r"^test/$", views.TestPage.as_view(), name="test"),
url(r"^thanks/$", views.ThanksPage.as_view(), name="thanks"),
url(r"^admin/", admin.site.urls),
url(r"^accounts/", include("accounts.urls", namespace="accounts")), #1
reference
url(r"^accounts/", include("django.contrib.auth.urls")), # 2
url(r"^posts/", include("posts.urls", namespace="posts")), # 3
url(r"^groups/",include("groups.urls",namespace="groups")),
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'bootstrap3',
'accounts',
'groups',
'posts',
姜戈五世(2,2,6,《最终》,0) 蟒蛇3.7 如果我遗漏了什么,请告诉我,谢谢 问题来源StackOverflow 地址:/questions/59385145/the-included-urlconf-simplesocial-urls-does-not-appear-to-have-any-patterns-in
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。