Changes between Initial Version and Version 1 of FormGenScript


Ignore:
Timestamp:
Jan 4, 2007, 1:06:12 PM (18 years ago)
Author:
Lllama
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FormGenScript

    v1 v1  
     1= FormGen Script =
     2
     3Since newforms will replace manipulators and produce forms for inclusion in templates there is no need for the [wiki:ScaffoldScript Scaffold Script] any more.
     4
     5The attached script will turn the model below into the Form below for use as a basis in your own application.
     6
     7Model:
     8{{{
     9class 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
     17Output:
     18{{{
     19class 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}}}
Back to Top