Unable to match URL in URL.conf in Django?
What am I doing wrong ?
My URL : http://localhost:8000/login/
The DEBUG log from Django :
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 file :
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admi开发者_如何学Pythonn.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')
)
## urls.py
urlpatterns = patterns('',
(r'',include('dealerpanel.urls')),
(r'^admin/', include(admin.site.urls))
)
Change the prefix for including dealerpanel.urls
to be the empty string. I think the way you have it structured it would actually be looking for a url like:
/login/login/
/login/home/
/home/login
...
Add something like this to your dealerpanel/urls.py
so that http://localhost:8000/login/
will hit the view dealerpanel.views.target_view
:
urlpatterns = patterns('dealerpanel.views',
...
(r'','target_view'),
)
This means the empty string after login
(or home
) will match the target_view
精彩评论