我做错了什么?
来自Django的DEBUG日志:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/login/
Using the URLconf defined in dealers.urls, Django tried these URL patterns, in this order:
^login|home/ ^login/$
^login|home/ ^home/$
^login|home/ ^home/dealer/(?P<dealer_id>\d+)/$
^admin/
The current URL, login/, didn't match any of these.
urls.py文件:
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^login|home/',include('dealerpanel.urls')),
(r'^admin/', include(admin.site.urls))
)
dealerpanel / urls.py:
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('dealerpanel.views',
(r'^login/$','login'),
(r'^home/$','home'),
(r'^home/dealer/(?P<dealer_id>\d+)/$','details')
)
答案 0 :(得分:4)
## urls.py
urlpatterns = patterns('',
(r'',include('dealerpanel.urls')),
(r'^admin/', include(admin.site.urls))
)
将包含dealerpanel.urls
的前缀更改为空字符串。我认为你构建它的方式实际上是在找一个像这样的网址:
/login/login/
/login/home/
/home/login
...
答案 1 :(得分:0)
将这样的内容添加到dealerpanel/urls.py
,以便http://localhost:8000/login/
能够点击dealerpanel.views.target_view
:
urlpatterns = patterns('dealerpanel.views',
...
(r'','target_view'),
)
这意味着login
(或home
)之后的空字符串将匹配target_view