Changes between Initial Version and Version 2 of Ticket #31124
- Timestamp:
- Dec 27, 2019, 4:43:37 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31124
- Property Component Uncategorized → Database layer (models, ORM)
- Property Easy pickings unset
- Property Resolution → needsinfo
- Property Status new → closed
- Property Summary get foo display - model inheritance does not work correctly → Model.get_FOO_display() does not work correctly with inherited choices.
-
Ticket #31124 – Description
initial v2 2 2 Child Model inherits the base model overrides the choices A and adds 2 more tuples 3 3 get_foo_display does not work correctly for the new tuples added 4 5 Example: 6 7 8 {{{ 9 class A(models.Model): 10 foo_choice = Choices(("A","output1"),("B","output2")) 11 field_foo = models.CharField(max_length=254,choices=foo_choice) 12 class Meta: 13 abstract:True 14 15 class B(A): 16 foo_choice = Choices(("A","output1"),("B","output2"),("C","output3")) 17 field_foo = models.CharField(max_length=254,choices=foo_choice) 18 }}} 19 20 Upon invoking get_field_foo_display() on instance of B , 21 For value "A" and "B" the output works correctly i.e. returns "output1" / "output2" 22 but for value "C" the method returns "C" and not "output3" which is the expected behaviour 23