Opened 4 years ago

Last modified 4 years ago

#14671 new Bug

Allow overriding of ModelChoiceField.choices

Reported by: simon29 Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: sprintdec2010
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

This patch fixes a validation bug when attempting to override choices manually on a ModelChoiceField. Comments in code suggest this should be able to be done.

Note, this used to work until the recent model/form validation changes.

Attachments (1)

modelchoicefield_choices.diff (1.3 KB) - added by simon29 4 years ago.

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by simon29

comment:1 Changed 4 years ago by simon29

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Note the patch has also swept up the addition of 'BaseModelFormSet', 'BaseInlineFormSet' to all (they can be useful!)

comment:2 Changed 4 years ago by cogat

  • Cc cogat added

comment:3 Changed 4 years ago by cogat

  • Cc cogat removed
  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

-1 on the addition of BaseModelFormSet to __all__. Although the classes can be useful, they are abstract, and can be imported explicitly with:

from forms.models import BaseModelFormSet

For the problem at hand, a test that illustrates the bug would help immensely. Reviewing the patch, it looks reasonable, except the choice of variable name for pk, given that something else could be in self.to_field_name.

comment:4 Changed 4 years ago by cogat

  • Keywords sprintdec2010 added

comment:5 Changed 4 years ago by mk

  • Needs documentation set
  • Patch needs improvement set

The patch needs documentation, tests and reasons why BaseModelFormSet and BaseInlineFormset should be added to all.

comment:6 Changed 4 years ago by jaddison

  • milestone 1.3 deleted
  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:8 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

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