I see inconsistencies in how get_*_display() works based on whether
the object is a recently saved object.  Probably an example describes
this best:

My model contains this:

class Task(models.Model):

    STATUS_CHOICES = (
        (OPEN_STATUS, 'Open'),
        (CLOSED_STATUS, 'Closed'),
        (STALLED_STATUS, 'Stalled'),)

    status = models.IntegerField(choices=STATUS_CHOICES, blank=True,
null=True)


If I get a Task object from the database (via a .get() or .filter()),
then my status field contains an integer and I can call
the .get_status_display() method, ie:

(Pdb) type(t)
<class 'taskmanager.models.Task'>
(Pdb) t.status
3
(Pdb) t.get_status_display()
u'Stalled'


However, if I have recently saved a modelForm associated with my Task
model and now have a handle to the object that that save() returned,
the status is in unicode, and get_status_display() doesn't return a
useful string:

(Pdb) type(self)
<class 'taskmanager.models.Task'>
(Pdb) self.status
u'3'
(Pdb) self.get_status_display()
u'3'

Is this expected behavior?

Margie


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