On Jun 6, 5:23 am, Jason Beaudoin <jasonbeaud...@gmail.com> wrote: > > - I've got a model that defines "submissions", which are incoming > messages from HTML forms on various websites and are fielded by admins > - each submission has a bunch of basic information related to the > submission (where, when, etc), as well as the data submitted by the > user (form input field) > - each form on each website is different, and will be different in the future > - allowing non-developers the ability to manage these forms would be > really nice, so creating them through a frontend interface (as opposed > to developers hardcoding forms) is a desirable goal > - the idea is that users would submit information from various source > websites to a central repository via a number of forms all with > different fields and varying in # of fields, field names, etc. the > central repository is a place where everything is reviewed, where > submissions are displayed in a "this is when it came in, from here, > and this is what the user gave us" type of way. > > I'm not sure how to save the form information with each submission, > given that each form will be different.. I'm used to defining specific > forms and only accepting specific information. >
Regarding form creation, you can create forms as it were procedurally: from django.core.exceptions import ValidationError from django.forms import forms from django.forms import fields from django.forms import widgets # factory def FormClass(name_, **kw): return forms.DeclarativeFieldsMetaclass(name_, (forms.BaseForm,), kw) # widgets Textarea = widgets.Textarea({'rows': '30'}) # fields NameField = fields.CharField(label='Name', max_length=50) BioField = fields.CharField(label='Bio', widget=Textarea, required=False) # validators def clean_name(form): if form.cleaned_data['name'].startswith('J'): raise ValidationError("Invalid User") return form.cleaned_data['name'] # forms RegistrationForm = FormClass( 'frm1234', name = NameField, bio = BioField, clean_name=clean_name, ) print type(RegistrationForm) form = RegistrationForm({'name': 'Bob'}) assert form.is_valid() form = RegistrationForm({'name': 'Joe'}) assert not form.is_valid() print form['name'] print form['name'].errors -- 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.