On Mar 27, 8:00 am, hc w <skysoari...@yahoo.com.cn> wrote:
> Hi, all
> I defined a choice field in model like bellow: 
>     sendchannel = models.CharField(max_length=1,choices=(('1','channel 
> 1'),('2','channel 2')))
> so how to  show the choice title but not value on template?  I scanned admin 
> templates . seems something like dict(choices).get(xxxx). just cannot figure 
> it out.  Anyone can help me? Thanks  

{{ model_instance.get_sendchannel_display }}

http://docs.djangoproject.com/en/dev//ref/models/instances/#django.db.models.Model.get_FOO_display

-Rajesh D

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to