I'm running into some perplexing regex issues in urls.py and getting, 'Stumpy.views.home', name='home'),
to my admin section.
It worked before but now that I have another view added in, anything
beyond the index regex is getting fed into the "url/" section rather
than admin:
I've included my urls.py section and the 500 error.
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^
# url(r'^Stumpy/', include('Stumpy.foo.urls')),
# show the index from /
url(r'^, 'shortener.views.index'),
# get a url for redirection /shorty
url(r'^(?P<short>\w+)/, 'shortener.views.detail'),
# send a url to be shortened from /url/someencodedurl
url(r'^url/(?P<url>\S+)/, 'shortener.views.submit'),
# Uncomment the admin/doc line below to enable admin
documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
judging by the 500 error it seems to be sending it to the submit view
No, the traceback below shows that the code is in the detail view.
Environment:
Request Method: GET
Request URL: http://192.168.11.4:8001/admin/
[snip]
Traceback:
File "/home/mugen/programming/django/django/core/handlers/base.py" in
get_response
111. response = callback(request, callback_args, **callback_kwargs)
File "/home/mugen/programming/Stumpy/shortener/views.py" in detail
11. thisurl = url.objects.get(shorturl=short) File "/home/mugen/
line 111 in views.py i(n detail).
Your urlpattern for this view is:
url(r'^(?P<short>\w+)/, 'shortener.views.detail'),
url patterns are scanned in order, and the first one that matches is used. /admin/ matches that regex.so detail is called.
Either move the entry for admin above this one (in which case you can never have a short value of "admin"), leave it where it is and give it a different prefix than /admin/ -- one that will not match this detail pattern, or change this detail pattern so that /admin/ does not match it.
(You should also fix your detail view so it does not generate a server error when called with a short value that does not exist...a 404 would be a more typical response to that situation.)
Karen
--
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment