Opened 16 years ago
Closed 16 years ago
#12331 closed (worksforme)
get_display shows choices key, not value if field name contains underscore symbol
| Reported by: | anonymous | Owned by: | nobody |
|---|---|---|---|
| Component: | Template system | Version: | dev |
| Severity: | Keywords: | choices, get_display | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
CURRENCY_CHOICES = (
(u"USD", u"$"),
(u"EUR", u"€"),
)
buyer_currency = models.CharField(u"Price", choices = CURRENCY_CHOICES, max_length=3, default='USD')
template:
{{user.userprofile.get_buyer_currency_display|safe}} shows "USD"
after rebuilding model with no underscore it works as it should:
{{user.userprofile.get_buyercurrency_display|safe}} shows "$"
Note:
See TracTickets
for help on using tickets.
I cannot recreate this. Using this model:
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: