Code

Opened 7 years ago

Closed 7 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:

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.

Attachments (1)

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

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by vsevolod.solovyov@…

comment:1 Changed 7 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.