I 'm trying to create a form dynamically. This works just fine, but there's no way for the form to offer any customized validation, by way of the clean() method.
def get_dept_weight_form(store): fields = {} s = Store.objects.get(pk=store.id) for d in store.department_set.all(): fields['id_%d' % d.id] = forms.DecimalField( label = d.name, initial = d.weight ) return type('WeightForm', (forms.BaseForm,), {'base_fields': fields}) Basically, this form spits out a label showing the department name and the weight for you to enter in a textbox. The weights for all departments should total 1.0. Should a clean() method handle this? I already use an overridden version of save() on the store model, but that just prints out a warning to stdout. Also, I have this validation for the admin part by overriding the clean method for my declared ModelForm. Perhaps I should just use the functionality I already created in models.py and just raise a ValidationError? Thx -- 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.