FormGen? Script
Maybe this is obsolete too: ModelForms? is simpler way to do it? Or if not, why is FormGen? better? http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
Since newforms will replace manipulators and produce forms for inclusion in templates there is no need for the Scaffold Script any more.
The attached script will turn the model below into the Form below for use as a basis in your own application.
Model:
class Category(models.Model): category = models.CharField(maxlength=50, unique=True) createdOn = models.DateField(auto_now_add=True) modifiedOn = models.DateField(auto_now=True) test = models.ManyToManyField(auth.User, verbose_name='This is a test field', related_name='test') test2 = models.OneToOneField(auth.User, verbose_name='test2', related_name='test2')
Output:
class CategoryForm(forms.Form): category = forms.CharField() createdon = forms.DateField() modifiedon = forms.DateField() test2 = forms.ChoiceField() this_is_a_test_field = forms.MultipleChoiceField()
Attachments
- formGen.py (1.3 kB) -
Initial upload
, added by Lllama on 01/04/07 13:07:05. - formGen.2.py (1.2 kB) -
This version uses the same names for form fields as the model fields. Not the verbose name.
, added by p.bach on 01/31/07 17:08:22. - form_generator.py (2.1 kB) -
Improved version of the form generating script, includes verbose_name, help_text, required and allows appending to files.
, added by Rick@Fawo.nl on 08/12/07 21:07:36.
