Hi all,
from a model object, I can get a related object shortcut,
using the name of the foreign key field:
>>> m1 = Mailbox.objects.get(pk=38)
>>> str(m1.localdomainfk)
'framailx.de'
But if I have the foreign key field instead of its name,
I can only get the pk of the related object:
>>> f1 = Mailbox._meta.get_field(‚localdomainfk')
>>> f1.value_from_object(m1)
7
Can anybody show me, how to get the related object
shortcut, if I have only the local object and the foreign key field?
Axel
-—
PGP-Key:29E99DD6 ☀ computing @ chaos claudius
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/E0D34B8F-B9A0-47AC-BFB0-43A3788A71E4%40Chaos1.DE.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment