Okay, here's the problem.
>>> f = dev._meta.get_field('distro')
>>> f.value_from_object(dev)
2L
value_from_object is defined as:
========================================================
def value_from_object(self, obj):
"Returns the value of this field in the given model instance."
return getattr(obj, self.attname)
========================================================
>>> 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.
>From what I can tell, value_from_object() is actually mis-named, and should
be named pkvalue_from_object(), no? Or is there some case where
self.attname
for a field is *not* set to the primary key attribute name?
Any ideas? I really want (concept)
"myfield.unicode_representation_of_object(myobject)"
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/VwIWznE_R-QJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.