Code

Opened 5 years ago

Closed 5 years ago

#11755 closed (fixed)

Django documentation on Model FormSets should include a tip on how to override default behavior

Reported by: ffualo Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords: modelformset_factory
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The documentation page "Creating forms from models" mentions:

"By default, when you create a formset from a model, the formset will use a queryset that includes all objects in the model (e.g., Author.objects.all()). You can override this behavior by using the queryset argument"

However, it does not mention how to override this behavior, which is useful when you want to print blank form fields in a template. This is done with

AuthorFormSet(queryset=Author.objects.none())

This issue was discussed on #django.

Attachments (1)

modelforms_change.diff (676 bytes) - added by ffualo 5 years ago.
A recommended documentation addition

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by ffualo

A recommended documentation addition

comment:1 Changed 5 years ago by Alex

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [11549]) Fixed #11755 -- Added documentation for an edge case of FormSet usage. Thanks to ffualo for the suggestion.

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.