作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
您好,我在进行迁移或使用 python manage.py runserver
命令时遇到此错误。
(urls.W005) URL namespace 'LnkIn' isn't unique.You may not be able to reverse all URLs in this namespace.
这就是我将 urls.py 放在我的应用程序目录 (LnkIn) 中的方式。
from django.conf.urls import url
from . import views
app_name = 'LnkdIn'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^register/$', views.register, name='register'),
url(r'^login_user/$', views.login_user, name='login_user'),
url(r'^logout_user/$', views.logout_user, name='logout_user'),
url(r'^(?P<user_id>[0-9]+)/$', views.profile, name='profile'),
url(r'^(?P<song_id>[0-9]+)/favorite/$', views.favorite, name='favorite'),
url(r'^trabajos/$', views.trabajos, name='trabajos'),
url(r'^crear_oferta/$', views.crear_oferta, name='crear_oferta'),
url(r'^(?P<user_id>[0-9]+)/create_trabajo/$', views.create_trabajo, name='create_trabajo'),
url(r'^(?P<user_id>[0-9]+)/crear_amistad/$', views.crear_amistad, name='crear_amistad'),
url(r'^(?P<user_id>[0-9]+)/delete_trabajo/(?P<trabajo_id>[0-9]+)/$', views.delete_trabajo, name='delete_trabajo'),
url(r'^(?P<album_id>[0-9]+)/favorite_album/$', views.favorite_album, name='favorite_album'),
url(r'^(?P<album_id>[0-9]+)/delete_album/$', views.delete_album, name='delete_album'),
]
这就是我在主目录中拥有 urls.py 的方式。
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^LnkdIn/', include('LnkdIn.urls')),
url(r'^', include('LnkdIn.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我真的不知道我做错了什么。我检查了我的 View 和模板,一切似乎都很好,我的网址上似乎没有任何拼写错误。我已经搜索但没有发现这个错误,我看起来很相似,他们建议检查网址中没有错误。
我正在使用 Python 2.7 和 Django 1.10。
最佳答案
您将 LnkdIn.urls
两次导入到您的应用程序 urlpatterns
。
你应该只做一次,所以从下面的部分中选择一个
url(r'^LnkdIn/', include('LnkdIn.urls')),
或
url(r'^', include('LnkdIn.urls')),
关于python - (urls.W005) URL 命名空间 'LnkIn' 不是唯一的。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43713239/
您好,我在进行迁移或使用 python manage.py runserver 命令时遇到此错误。 (urls.W005) URL namespace 'LnkIn' isn't unique.You
我是一名优秀的程序员,十分优秀!