CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/html;charset=utf-8
cache-control: must-revalidate
expires: Fri, 01 Jan 1999 00:00:00 GMT
set-cookie: trac_form_token=f0258d2ff7c2f7b9763a7dcf; HttpOnly; Path=/; Secure
set-cookie: trac_session=6cb62cdfb6980ad7422cd108; expires=Tue, 21 Oct 2025 05:29:05 GMT; HttpOnly; Path=/; Secure
strict-transport-security: max-age=31536000; includeSubDomains; preload
permissions-policy: interest-cohort=()
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
accept-ranges: bytes
via: 1.1 varnish, 1.1 varnish
date: Wed, 23 Jul 2025 05:29:05 GMT
x-served-by: cache-fra-eddf8230097-FRA, cache-bom-vanm7210097-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753248546.723811,VS0,VE268
vary: Accept-Encoding
FormGenScript – Django
Back to Top
Django
The web framework for perfectionists with deadlines.
Issues
FormGen Script
Maybe this is obsolete too: ModelForms is simpler way to do it? Or if not, why is FormGen better? https://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()
Last modified
16 years ago
Last modified on May 22, 2009, 4:50:56 PM
Attachments (3)
-
formGen.py
(1.3 KB
) - added by Lllama 19 years ago.
Initial upload
-
formGen.2.py
(1.2 KB
) - added by p.bach 18 years ago.
This version uses the same names for form fields as the model fields. Not the verbose name.
-
form_generator.py
(2.1 KB
) - added by Rick@… 18 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
Note:
See TracWiki
for help on using the wiki.
Download in other formats:
Django Links
Learn More
Get Involved
Follow Us
- Hosting by In-kind donors
- Design by Threespot &
© 2005-2025 Django SoftwareFoundation unless otherwise noted. Django is a registered trademark of the Django Software Foundation.