how to use generic_inlineformset_factory ?

793 views
Skip to first unread message

Marco Louro

unread,
Dec 7, 2008, 10:46:49 PM12/7/08
to Django users
Hi,

I'm trying to use generic_inlineformset_factory. There are no docs for
it except a Generic Relations Model example @
http://www.djangoproject.com/documentation/models/generic_relations/
on the bottom (GenericInlineFormSet tests)

My question here is how to pass the POST vars to it?

In a modelformset_factory the following works:
formset = AddressFormSet(request.POST, request.FILES)

but here it is not the case..

Malcolm Tredinnick

unread,
Dec 7, 2008, 11:07:23 PM12/7/08
to django...@googlegroups.com

Can you be specific about what is not working? If you look at the source
for GenericInlineFormset, it certainly takes those parameters as the
first two arguments. So what are you actually doing and what error are
you seeing? (trim your example down the smallest possible code that
shows the problem so we don't have to wade through dozens of lines.)

Regards,
Malcolm


Marco Louro

unread,
Dec 7, 2008, 11:28:45 PM12/7/08
to Django users
Thanks for quick reply Malcom.

This is the code for my view.
I know I'm missing something, the formsets do show up correctly on the
form page, but I'm just not seeing how to load the request.POST data
into the formset for validation and save

The error I get is:
Exception Value: 'Manager' object has no attribute 'empty'
Exception Location: /usr/lib/python2.5/site-packages/django/contrib/
contenttypes/generic.py in get_queryset, line 310


def add(request,contact_type):

AddressFormSet = generic_inlineformset_factory(Address, extra=2)

if request.method == 'POST':
address_formset = AddressFormSet(request.POST,request.FILES)
else:
address_formset = AddressFormSet(instance=Person.objects.get
(id=2))


I've also tried loading with
address_formset = AddressFormSet(Person,BaseGenericInlineFormSet
(request.POST,request.FILES))

Exception Value:
'NoneType' object has no attribute '_meta'
Exception Location: /usr/lib/python2.5/site-packages/django/contrib/
contenttypes/generic.py in __init__, line 295


On Dec 8, 4:07 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Marco Louro

unread,
Dec 8, 2008, 2:51:09 AM12/8/08
to Django users
Well, i've spent countless hours on this, and it was so easy.. I guess
it could be added to the docs since It's a really nice feature.

I've posted my very bad view code at dpaste, but it might be enough if
anyone who has a similar problem
http://dpaste.com/hold/96937/

Angel Felipe González Garcia

unread,
Apr 17, 2017, 3:56:56 PM4/17/17
to Django users, mlo...@gmail.com
Hi Marcos , how are you? i would like to know about Generic  Inline formset factory, i tried to acces to your dpaste code but it has expired, can you please provide other link or shar your explanation or code by this same way? regards

MohammadReza Kasaie Sharifi

unread,
Sep 23, 2019, 8:42:31 AM9/23/19
to Django users
I want ti open the link but it was expired

Deep Sukhwani

unread,
Sep 24, 2019, 12:01:49 AM9/24/19
to django...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9d0635d1-6067-4dc1-9f2e-1df1fe0799c7%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages