Situation in short. For some reason reverse() method does not work.
in PROJECT urls.py
url(r'^enrollment/', include('project.enrollment.urls')),
in APP urls.py
url(r'^thanks/$', 'enrollment.views.thanks', name='enroll_thanks'),
and in views.py
from django.core.urlresolvers import reverse
def thanks(request):
return render_to_response('enrollment/thanks.html', {}, context_instance=RequestContext(request))
def enroll(request):
''' some code for handling the form'''
return HttpResponseRedirect(reverse('enrollment.views.thanks'))
This reverse causes following error: Could not import project.views. Error was: No module named views
in file ../django/core/urlresolvers.py in _get_callback, line 167
Any idea why this does not work? Next step is to call the thanks-view with a parameter, but that should be easy after this setup works. Should there be something more to be imported in views.py?
From the docs for reverse: "As part of working out which URL names map to which patterns, the reverse() function has to import all of your URLconf files and examine the name of each view. This involves importing each view function. If there are any errors whilst importing any of your view functions, it will cause reverse() to raise an error, even if that view function is not the one you are trying to reverse."
Are any of your urls referencing project.views.
...?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With