|Version 2 (modified by Lllama, 8 years ago) (diff)|
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.
class Category(models.Model): category = meta.CharField(maxlength=50, unique=True) createdOn = meta.DateField(auto_now_add=True) modifiedOn = meta.DateField(auto_now=True) test = meta.ManyToManyField(auth.User, verbose_name='This is a test field', related_name='test') test2 = meta.OneToOneField(auth.User, verbose_name='test2', related_name='test2')
class CategoryForm(forms.Form): category = forms.CharField() createdon = forms.DateField() modifiedon = forms.DateField() test2 = forms.ChoiceField() this_is_a_test_field = forms.MultipleChoiceField()
(1.3 KB) -
added by Lllama 8 years ago.
(1.2 KB) -
added by p.bach 8 years ago.
This version uses the same names for form fields as the model fields. Not the verbose name.
(2.1 KB) -
added by Rick@… 8 years ago.
Improved version of the form generating script, includes verbose_name, help_text, required and allows appending to files.
Download all attachments as: .zip