this might be a slightly broad question, but in essence, I'd like to allow my site's users to be able to add fields (text or char fields) to forms so that other users can fill them out. How exactly should I structure my models/forms/views to allow for this type of customization? Thanks!
Using metaclass:
from django.forms import BaseForm
fields = {
'name': forms.CharField(max_length=50),
'id': forms.IntegerField()
}
type('CustomForm', (BaseForm,), { 'base_fields': fields })
For a more comprehensive approach, use django-forms-builder:
http://django-forms-builder.readthedocs.org/en/latest/
Mezzanine also supports this:
http://mezzanine.jupo.org/docs/packages.html#module-mezzanine.forms
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With