Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 30, 2011 10:35:32

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

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:

============ Examplehttp://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+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 30, 2011 13:31:08

Jonas G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

example do not work, TypeError


> ... print form.as_table() # ERROR 'WordFormFormSet' object is
> not iterable


Sounds like pretty obvious error to me.
You can't iterate over the WordFormFormSet object.

just write formsetw.as_table().




--
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+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support