This is pretty standard behavior in Django.

Have something like this in your models.py:

LOG_CODES = (
        ('Input', 1),
        ('Output', 2),
)

Then, the model field should have this in its definition:
        choices = LOG_CODES

If you name that field name, say, _transaction_type, then you can
define a function in your model called transaction_type which returns the
proper text value for the numeric value.

To make things even easier, put an @property decorator right before
that function definition, and you can call modelname.transaction_type
instead of modelname.transaction_type(). That makes the syntax the
same as you would expect for a property of a model.

Shawn


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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