On Mar 7, 4:27 pm, timlash <timl...@gmail.com> wrote: > I've read the doc several times but am still confused by the way > Django references URLs. I'm running Python 2.4 and Django 1.0.2 on my > Debian Etch box. > > My urls.py reads: > > from django.conf.urls.defaults import * > from django.conf import settings > > urlpatterns = patterns('my_proj.my_app.views', > (r'^admin/', include('django.contrib.admin.urls')), > (r'^my_app/$', 'index'), > (r'^my_app/home/$', 'index'), > (r'^my_app/page1/$', 'page1'), > (r'^my_app/page1/response/$', 'response'), > (r'^my_app/page2/$', 'page2'), > (r'^my_app/accounts/', include('registration.urls')), > ) > > And I have the following line in the resp() function of views.py: > > return HttpResponseRedirect(reverse > ('my_proj.my_app.views.response', args=(request,))) > > This line is causing the following error: > > Request Method: POST > Request URL: http://localhost:8000/my_app/page1/resp/ > Exception Type: ViewDoesNotExist > Exception Value: Tried page2 in module my_proj.my_app.views. > Error was: 'module' object has no attribute 'page2' > > Shouldn't the reverse() call resolve to "http://localhost:8000/my_app/ > page1/response/"?
Actually, no - none of the URLs match your call, since you're passing in an extra argument. I suspect you're doing this because the view takes the 'request' parameter, but you don't want to put this in the reverse call - you just use the arguments that would be passed from the URL, and none of your URLs take arguments. However, this isn't the source of your problem. Before it tries to match any URLs, Django imports all the views. It's telling you that it can't do that because your 'page2' view doesn't exist. Fix that (or comment out the reference to page2), plus the issue above, and it should work. -- DR. --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---