Opened 18 years ago

Closed 18 years ago

#4694 closed (wontfix)

Custom method for Model to simplify getting formfields

Reported by: vsevolod.solovyov@… Owned by: Adrian Holovaty
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no
Pull Requests:How to create a pull request

Description

This method will simplify creating of complex forms. Now it's clear what fields belong to what models.

class BookmarkForm(Form):
    url = Bookmark.get_form_field('url')
    title = Scrapbook.get_form_field('title')
    description = Scrapbook.get_form_field('description')

Instead of:

class BookmarkForm(Form):
    url = forms.URLField(max_length=200, verify_exists=False, label=u'URL')
    title = forms.CharField(max_length=256, required=False, label=u'Title')
    description = forms.CharField(required=False, label=u'Description', widget=forms.Textinput())

If patch itself is ok, I'll write documentation and tests.

Change History (2)

by vsevolod.solovyov@…, 18 years ago

Attachment: get_form_field.diff added

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: wontfix
Status: newclosed

Thanks for the patch, but I don't think this is worth including. Putting one model after another in a form like this is only one of many cases and we can't have special methods for every case. If anybody wanted to do this, it's only one line in their code in any case.

Note: See TracTickets for help on using tickets.
Back to Top