Sunday, January 30, 2011

example do not work, TypeError

simple question related to another example.
Django Version: 1.2.4
Exception Type: TypeError
Exception Value: 'WordFormFormSet' object is not iterable
Exception Location: c:\Python27\Scripts\Finnish2\..\Finnish2\Fin
\views.py in first, line 2492

# c:\Python27\lib\site-packages\django\core\handlers\base.py in
get_response
100. response = callback(request, *callback_args,
**callback_kwargs) ...

# c:\Python27\Scripts\Finnish2\..\Finnish2\Fin\views.py in first
2492. for form in formsetw:

============ Example
http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/

>>> AuthorFormSet = modelformset_factory(Author, max_num=4, extra=2)
>>> formset = AuthorFormSet(queryset=Author.objects.order_by('name'))

>>> for form in formset:
... print form.as_table() # ERROR 'WordFormFormSet' object is
not iterable

============= MY CODE

################## views.py

def first(request):
from django.forms.models import modelformset_factory
w=modelformset_factory(Word, max_num=4, extra=2)
formsetw=wFormSet( queryset=Word.objects.filter( Q
(Wordword__contains='jouluku')) )

print 'formset=', formset #prints long list of rows, why not
only 4

for form in formsetw:
print form.as_table()
form.save(commit=False)


--
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