Sunday, January 30, 2011

How to display empty custom or model based formset? form?

How to display empty custom or model based formset? form?

I am able to display only formset filled with data.

from django.forms.models import modelformset_factory
wFormSet=modelformset_factory(Word, max_num=4, extra=2,
fields=('Wordword', 'WordTranslEn')

#uncomment one of formsets. THIS EMPTY DO NOT WORK
#formsetw0=wFormSet()
# return render_to_response("c:/Python27/Scripts/Finnish2/Fin/
templates/trials/second.html", {
"formsetw": formsetw})

#THIS WORKS CORRECT
formsetw=wFormSet(queryset=Word.objects.filter(Q(Wordword__contains='joul')))
return render_to_response("c:/Python27/Scripts/Finnish2/Fin/
templates/trials/second.html", {
"formsetw": formsetw0})

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