Opened 9 years ago

Closed 9 years ago

#4694 closed (wontfix)

Custom method for Model to simplify getting formfields

Reported by: vsevolod.solovyov@… Owned by: adrian
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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.

Attachments (1)

get_form_field.diff (655 bytes) - added by vsevolod.solovyov@… 9 years ago.

Download all attachments as: .zip

Change History (2)

Changed 9 years ago by vsevolod.solovyov@…

comment:1 Changed 9 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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