Quantcast

how to use generic_inlineformset_factory ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to use generic_inlineformset_factory ?

Marco Louro

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

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use generic_inlineformset_factory ?

Malcolm Tredinnick


On Sun, 2008-12-07 at 19:46 -0800, Marco Louro wrote:

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

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



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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use generic_inlineformset_factory ?

Marco Louro

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 <[hidden email]>
wrote:

> On Sun, 2008-12-07 at 19:46 -0800, Marco Louro wrote:
> > 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..
>
> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use generic_inlineformset_factory ?

Marco Louro

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/



On Dec 8, 4:28 am, Marco Louro <[hidden email]> wrote:

> 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 <[hidden email]>
> wrote:
>
> > On Sun, 2008-12-07 at 19:46 -0800, Marco Louro wrote:
> > > 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..
>
> > 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use generic_inlineformset_factory ?

Angel Felipe González Garcia
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

El lunes, 8 de diciembre de 2008, 3:51:09 (UTC-4), Marco Louro escribió:
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
<a href="http://dpaste.com/hold/96937/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdpaste.com%2Fhold%2F96937%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFX4ZpgQHBIFqBVLr1AHDfIDX72ig&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdpaste.com%2Fhold%2F96937%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFX4ZpgQHBIFqBVLr1AHDfIDX72ig&#39;;return true;">http://dpaste.com/hold/96937/



On Dec 8, 4:28 am, Marco Louro <[hidden email]> wrote:

> 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 <[hidden email]>
> wrote:
>
> > On Sun, 2008-12-07 at 19:46 -0800, Marco Louro wrote:
> > > Hi,
>
> > > I'm trying to use generic_inlineformset_factory. There are no docs for
> > > it except a Generic Relations Model example @
> > ><a href="http://www.djangoproject.com/documentation/models/generic_relations/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.djangoproject.com%2Fdocumentation%2Fmodels%2Fgeneric_relations%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFOBQ7yvZKhaAJpiDfyO3Zzi2jJNw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.djangoproject.com%2Fdocumentation%2Fmodels%2Fgeneric_relations%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFOBQ7yvZKhaAJpiDfyO3Zzi2jJNw&#39;;return true;">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..
>
> > 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

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e7c6084d-5f7d-4848-9c9d-4fd38ea9c387%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...