Pass the form class to modelformset_factory() in the form argument.
The factory will then use the AuthorForm class as the base form class
when it creates the modelform class for the formset.

modelFormset = modelformset_factory(Author, form=AuthorForm)

On Tue, May 18, 2010 at 7:08 AM, Michael Davis
<davis.j.mich...@gmail.com> wrote:
>
> I am new to Django and am trying to get a custom modelForm to work in
> a ModelFormset_factory. For example:
>
> # in models.py
> class Author(models.Model):
>    name = models.CharField()
>    address = models.CharField()
>    phone = models.CharField()
>
> class AuthorForm(ModelForm):
>    class Meta:
>        model = Author
>
> # in views.py
> def authorForm(request):
>    modelFormset = modelformset_factory(Author)
>    items = Author.objects.all()
>    formsetInstance = modelFormset(queryset=items)
>    return render_to_response('blah',locals())
>
> The above code works fine, but I'd like to be able to tweak the
> default presentation of the AuthorForm and use that in the
> formset_factory. Is there any way to do that through the AuthorForm
> class above? If not is there another nearly easy way?
>
> Thanks
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
=======================================
株式会社ビープラウド  イアン・ルイス
〒150-0021
東京都渋谷区恵比寿西2-3-2 NSビル6階
email: ianmle...@beproud.jp
TEL:03-6416-9836
FAX:03-6416-9837
http://www.beproud.jp/
=======================================

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to