#31124: Model.get_FOO_display() does not work correctly with inherited choices.
-------------------------------------+-------------------------------------
     Reporter:  Yash Jhunjhunwala    |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Old description:

> Given a base model with choices A containing 3 tuples
> Child Model inherits the base model overrides the choices A and adds 2
> more tuples
> get_foo_display does not work correctly for the new tuples added

New description:

 Given a base model with choices A containing 3 tuples
 Child Model inherits the base model overrides the choices A and adds 2
 more tuples
 get_foo_display does not work correctly for the new tuples added

 Example:


 {{{
 class A(models.Model):
    foo_choice = Choices(("A","output1"),("B","output2"))
    field_foo = models.CharField(max_length=254,choices=foo_choice)
    class Meta:
        abstract:True

 class B(A):
    foo_choice = Choices(("A","output1"),("B","output2"),("C","output3"))
    field_foo = models.CharField(max_length=254,choices=foo_choice)
 }}}

 Upon invoking get_field_foo_display() on instance of B ,
 For value "A" and "B" the output works correctly i.e. returns "output1" /
 "output2"
 but for value "C" the method returns "C" and not "output3" which is the
 expected behaviour

--

Comment (by Yash Jhunjhunwala):

 Replying to [comment:1 felixxm]:
 > Thanks for this report. Can you provide models and describe expected
 behavior? Can you also check if it's not a duplicate of #30931?, that was
 fixed in Django 2.2.7.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31124#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.dcf1631b9b7add12dd998d5502817bfd%40djangoproject.com.

Reply via email to