| 1 | = FormGen Script = |
| 2 | |
| 3 | Since newforms will replace manipulators and produce forms for inclusion in templates there is no need for the [wiki:ScaffoldScript Scaffold Script] any more. |
| 4 | |
| 5 | The attached script will turn the model below into the Form below for use as a basis in your own application. |
| 6 | |
| 7 | Model: |
| 8 | {{{ |
| 9 | class Category(models.Model): |
| 10 | category = meta.CharField(maxlength=50, unique=True) |
| 11 | createdOn = meta.DateField(auto_now_add=True) |
| 12 | modifiedOn = meta.DateField(auto_now=True) |
| 13 | test = meta.ManyToManyField(auth.User, verbose_name='This is a test field', related_name='test') |
| 14 | test2 = meta.OneToOneField(auth.User, verbose_name='test2', related_name='test2') |
| 15 | }}} |
| 16 | |
| 17 | Output: |
| 18 | {{{ |
| 19 | class CategoryForm(forms.Form): |
| 20 | category = forms.CharField() |
| 21 | createdon = forms.DateField() |
| 22 | modifiedon = forms.DateField() |
| 23 | test2 = forms.ChoiceField() |
| 24 | this_is_a_test_field = forms.MultipleChoiceField() |
| 25 | }}} |