On Monday, March 28, 2011 2:04:53 PM UTC+1, luca72 wrote:
hello i have a form like this:
class Form_news(forms.Form):
messgg = forms.CharField(label = 'Messaggio',max_length=10000,
widget=forms.Textarea)
and in the views i do as follow:
if request.user.is_superuser:
if request.method == 'POST':
if form.is_valid():
form = Form_news(request.POST)
mess = form.cleaned_data['messgg']
i get the error form News has not attribute cleaned_data
Why?
Your code makes no sense: you're testing if the form is valid before you instantiate it with the POST data. It should be the other way round, of course:
if request.method == 'POST':
form = Form_news(request.POST)
if form.is_valid():
...etc...
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment