#33964: get_FOO_display() doesn't work with field named that include underscore
-------------------------------------+-------------------------------------
     Reporter:  80nph1r3             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |  worksforme
     Keywords:  get_FOO_display()    |             Triage Stage:
  model                              |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => worksforme


Comment:

 The following test passes for me. Please provide details to reproduce.
 {{{#!diff
 diff --git a/tests/model_regress/models.py b/tests/model_regress/models.py
 index 350850393a..369eada93f 100644
 --- a/tests/model_regress/models.py
 +++ b/tests/model_regress/models.py
 @@ -11,6 +11,7 @@ class Article(models.Model):
      status = models.IntegerField(blank=True, null=True, choices=CHOICES)
      misc_data = models.CharField(max_length=100, blank=True)
      article_text = models.TextField()
 +    the_status = models.IntegerField(blank=True, null=True,
 choices=CHOICES)

      class Meta:
          ordering = ("pub_date", "headline")
 diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py
 index 10dfbabcd9..cd7c6f3c48 100644
 --- a/tests/model_regress/tests.py
 +++ b/tests/model_regress/tests.py
 @@ -56,8 +56,9 @@ class ModelTests(TestCase):
          # NOTE: Part of the regression test here is merely parsing the
 model
          # declaration. The verbose_name, in particular, did not always
 work.
          a = Article.objects.create(
 -            headline="Look at me!", pub_date=datetime.datetime.now()
 +            headline="Look at me!", pub_date=datetime.datetime.now(),
 the_status=1,
          )
 +        self.assertIs(a.get_the_status_display(), 'first')
          # An empty choice field should return None for the display name.
          self.assertIs(a.get_status_display(), None)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33964#comment:1>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182e9ba6270-dbeb4ab1-9033-4e7e-85d5-1c3da18572d9-000000%40eu-central-1.amazonses.com.

Reply via email to