It can be improved.

My suggestion is to use lower_underscored for methods names and you can
do something like this:
        delete the method in your model because django models allready provides
a method for your choice fields:
        get_field_display()
        for your field would be:
        get_status_display()

in your template you will have {{ m.get_status_display() }}

read more on this here:
http://docs.djangoproject.com/en/dev/ref/models/fields/#choices

At first i didn't knew status is a choices field.


On Fri, 2009-10-09 at 01:15 -0700, valler wrote:
> Thank you, this was the most beautiful solution.
> I post it here, in case if someone will search it:
> 
> class Msg(models.Model):
>   ......
>   ......
>   ......
> 
>   status = models.IntegerField(choices=MSG_STATUS_LIST)
>   def getStatus(self):
>     return MSG_STATUS_LIST[self.status][1]
> 
> in template:
> 
> {{m.getStatus}}
> > 


--~--~---------~--~----~------------~-------~--~----~
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