Re: Can't get a Chapter 7 example to work.
Glad you solved it :)
Cheers
On Sun, May 13, 2012 at 4:07 AM, django-user59 <venkat.rangan@gmail.com> wrote:
Found the problem!The urls.py was set incorrectly -changed from:url(r'^contact/$', 'demoapp.contact.views.ContactForm'),to:url(r'^contact/$', 'demoapp.contact.views.contact'),
and that makes it work.
Thanks - your hint that the object was not a HttpResponse was important one to pursue.To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/IKBfOVtf7m0J.--
On Saturday, May 12, 2012 8:07:52 AM UTC-7, django-user59 wrote:Yati,Thanks so much for a fast response.Here is my views.py code - I thought I'm returning an instance of HttpResponse.from django.http import HttpResponseRedirectfrom django.core.mail import send_mailfrom django.shortcuts import render_to_responsefrom demoapp.contact.forms import ContactFormdef contact(request):if request.method == 'POST':form = ContactForm(request.POST)if form.is_valid():cd = form.cleaned_datasend_mail(cd['subject'],cd['message'],cd.get('email', 'xyz@example.com'),['xyz@example.com'],)return HttpResponseRedirect('/contact/thanks/')else:form = ContactForm(initial={'subject': 'I love your site'})return render_to_response('contact_form.html', {'form': form})
On Saturday, May 12, 2012 8:01:57 AM UTC-7, yati sagade wrote:My wild guess is that you're returning an instance of ContactForm in one of your views. A view should return an HttpResponse object. Check your view that uses this formOn Sat, May 12, 2012 at 8:21 PM, django-user59 wrote:
Hi,
I could not get the Chapter 7 "contact" form example to work. The
public copy-paste is here: http://dpaste.com/747112/copy/
The message I get is:
AttributeError at /contact/
'ContactForm' object has no attribute 'status_code'
My ContactForm definition is as follows:
from django import forms
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
email = forms.EmailField(required=False, label='Your e-mail
address')
message = forms.CharField(widget=forms.Textarea)
def clean_message(self):
message = self.cleaned_data['message']
num_words = len(message.split())
if num_words < 4:
raise forms.ValidationError("Not enough words!")
return message
--
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.
--
Yati Sagade
Twitter: @yati_itay
Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869
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.
--
Yati Sagade
Twitter: @yati_itay
Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home