On 02/07/15 13:56, Vijay Khemlani wrote:
> You could dynamically create a ModelForm based on the model class:
>
> from django.forms import ModelForm
>
> MetaClass = type('Meta', (), {'model': ProductItemText})
>
> MetaModelForm = type('ProductModelForm', (ModelForm, ), {'Meta': MetaClass})
>
> form = MetaModelForm()
>
> The only thing you would need is the model class itself
> ("ProductItemText" in this particular case), I think you could even add
> it as a classmethod to the base Product class.
Hi,
Thanks for the reply.
I'm a bit confused about what this does. Can you explain a little bit.
I'd like to understand what is going on in the above code a little better.
Thanks.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55953B40.2030701%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment