On 21 June 2011 15:47, Jeff Blaine <cjbla...@gmail.com> wrote: > Okay, here's the problem. > > >>> f = dev._meta.get_field('distro') > >>> f.value_from_object(dev) > 2L > > >>> f.attname > 'distro_id' > >>> > > As others guessed, value_from_object() is returning the pk ID in this > case. > > Model "Distro" is the only model of mine showing this behavior, as it is the > only foreign key "target" model I have defined without named primary key. > > No, I think you're seeing the same behaviour for all fields - ie you're retrieving the value of the key for the related item. However for the Status model, that value is a string since you've defined a charfield as the primary key.
Under the hood, related fields store the key of the related item, not the item itself. Clever Stuff (TM) in the ORM then reifies those objects as needed. Malcolm -- 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.