Problems with HttpResponseRedirect(reverse()) No match found
Hi,
I've read the django docs here: http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse
and am still having trouble with redirecting my views. Here is my
view:
def skipant_sale(request, notes=''):
notes=notes
if request.method == 'POST': # If the form has been submitted...
form = ContactForm_Sale(request.POST) # A form bound to the
POST data
if form.is_valid(): # All validation rules pass
name = form.cleaned_data['name']
message = form.cleaned_data['message']
phone = form.cleaned_data['phone']
your_email = form.cleaned_data['your_email']
retype_email = form.cleaned_data['retype_email']
subject=form.cleaned_data['subject']
if your_email==retype_email:
message=message+': Phone '+phone +': Name '+name
from django.core.mail import send_mail
send_mail(subject, message, your_email,
['malcolm@sporthill.com'])
else:
notes='Sorry, there was a problem with your
submission. Please try again or contact us at the phone number below.
Thanks!'
return HttpResponseRedirect(reverse
('onhand.views.email_sale', kwargs={'notes':notes}))
form = ContactForm_Sale()
notes="We have received your email, and will contact you
soon to answer any questions you may have. Thank you!"
return HttpResponseRedirect(reverse
('onhand.views.email_sale', kwargs={'notes':notes}))
else:
form = ContactForm_Sale() # An unbound form
return render_to_response('yui_temp.html', {'form' : form,},
context_instance = RequestContext(request))
def email_sale(request, notes=''): #redirect back to skipant_sale
view.
return HttpResponseRedirect(reverse('onhand.views.skipant_sale',
kwargs={'notes':notes,}))
Here is my url:
(r'^skipant_sale/$', 'onhand.views.skipant_sale'),
Whenever I've tried this, I keep getting the error message no match
found. Any help would be very much appreciated. Thanks!
Environment:
Request Method: POST
Request URL: http://baglux.sporthill.com/skipant_sale/
Django Version: 1.2 pre-alpha SVN-11616
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'orders1.onhand',
'registration',
'pagination',
'django.contrib.flatpages',
'tinymce',
'sorl.thumbnail',
'django.contrib.sitemaps']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',
'django.middleware.ssll.SSLRedirect',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'pagination.middleware.PaginationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/malcolm/data1/orders1/onhand/views.py" in skipant_sale
2089. return HttpResponseRedirect(reverse
('onhand.views.email_sale', kwargs={'notes':notes}))
File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in
reverse
350. *args, **kwargs)))
File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in
reverse
300. "arguments '%s' not found." % (lookup_view_s,
args, kwargs))
Exception Type: NoReverseMatch at /skipant_sale/
Exception Value: Reverse for 'onhand.views.email_sale' with arguments
'()' and keyword arguments '{'notes': 'We have received your email,
and will contact you soon to answer any questions you may have. Thank
you!'}' not found.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home