Code

Opened 5 years ago

Closed 5 years ago

#11187 closed (wontfix)

Documentation: Explicit is better than implicit.

Reported by: arbitraryuser Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The short version:
I think it might make sense to modify the documentation at http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method to say >>> f = ArticleForm(data=request.POST) rather than just >>> f = ArticleForm(request.POST) as users will run into 'non-keyword arg after keyword arg' issues when using more advanced incantations of ModelForm.

The long version:
I ran into a problem with http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method because I was passing my form def an additional varible with which to limit the options of drop down box. This works fine until you are also doing a ModelForm based update and need to pass data, your instance *and* an object that you want to filter with. I had to in the source to see what the arg's name actually was.

PS. Loving Django so f-ing much right now... :)

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by Alex

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

Passing it as a positional argument is a completely valid way to instantiate a form, this is not a case of explicit vs. implicit.

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.