(urls.W005)URL名称空间“ LnkIn”不是唯一的。 [英] (urls.W005) URL namespace 'LnkIn' isn't unique.

查看:230
本文介绍了(urls.W005)URL名称空间“ LnkIn”不是唯一的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在进行迁移或使用 python manage.py runserver 命令时遇到此错误。

Hi I'm getting this error when doing my migrations or using the python manage.py runserver command.

(urls.W005) URL namespace 'LnkIn' isn't unique.You may not be able to reverse all URLs in this namespace. 

这是我将urls.py放在应用程序目录(LnkIn)中的方式。

This is how I have my urls.py inside my app directory (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的方式。

And this is how I have my urls.py in my main directory.

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)

我真的不知道该怎么做。我查看了自己的视图和模板,一切似乎都很好,我的网址似乎没有任何错字。我已经搜索过,但没有发现此错误,似乎与之相似,他们建议您检查网址中是否存在错误。

I really have no idea what could I've done wrong. I checked in my views and in my templates and everything seems to be fine, I don't seem to be having any typo on my urls. I've search but haven't find this error, I've seem similars one and they suggest to check not having mistakes in the urls.

我正在使用Python 2.7和Django 1.10。

I'm using Python 2.7 and Django 1.10.

推荐答案

您两次将 LnkdIn.urls 导入到应用程序 urlpatterns

You are importing LnkdIn.urls twice to your application urlpatterns.

您应该只做一次,所以从下面的部分中选择一个

You should only do it once, so choose either one from the section below

url(r'^LnkdIn/', include('LnkdIn.urls')),

url(r'^', include('LnkdIn.urls')),

这篇关于(urls.W005)URL名称空间“ LnkIn”不是唯一的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆