#12331: get_display shows choices key, not value if field name contains 
underscore
symbol
--------------------------------------+-------------------------------------
          Reporter:  anonymous        |         Owner:  nobody              
            Status:  closed           |     Milestone:                      
         Component:  Template system  |       Version:  SVN                 
        Resolution:  worksforme       |      Keywords:  choices, get_display
             Stage:  Unreviewed       |     Has_patch:  0                   
        Needs_docs:  0                |   Needs_tests:  0                   
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Changes (by kmtracey):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => worksforme
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I cannot recreate this.  Using this model:

 {{{
 #!python
 from django.contrib.auth.models import User
 class CTest(models.Model):
     CURRENCY_CHOICES = (
         (u"USD", u"$"),
         (u"EUR", u"€"),
     )
     buyer_currency = models.CharField(u"Price", choices =
 CURRENCY_CHOICES, max_length=3, default='USD')
     buyercurrency = models.CharField(u"Price2", choices =
 CURRENCY_CHOICES, max_length=3, default='EUR')
     user = models.ForeignKey(User)
     def __unicode__(self):
         return u'Profile for %s: buyer_currency = %s, buyercurrency = %s'
 % \
                  (self.user.username, self.buyer_currency,
 self.buyercurrency)

 }}}

 specified as AUTH_PROFILE_MODULE in settings.py, with a view that passes a
 !RequestContext to a template that includes:

 {{{
 User is {{ user }} <br/>
 {{ user.get_profile }} <br/>
 get_buyer_currency_display returns:
 {{user.get_profile.get_buyer_currency_display|safe}} <br/>
 get_buyercurrency_display returns:
 {{user.get_profile.get_buyercurrency_display|safe}} <br/>
 }}}

 The displayed page when logged in with a user that has a profile shows:

 {{{
 User is kmt
 Profile for kmt: buyer_currency = USD, buyercurrency = EUR
 get_buyer_currency_display returns: $
 get_buyercurrency_display returns: €
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12331#comment:1>
Django <http://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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.


Reply via email to