How/When does Django calculate the ForeignKey object
I have a models开发者_运维百科 class class A(models.Model): user = models.ForeignKey(User)
Now if I do a a = A.objects.get(pk = something_existing); print a.__dict__, user is not in __dict__. a.user however doesnot give an attribute error.
So when is the actual user being calculated? I looked in django.db.models.base.Model and django.db.models.base.ModelBase classes and they do not override __getattr__, (which I guessed might be being done), so where is this calculated/populated.
Django relation fields are implemented as descriptors.
加载中,请稍侯......
精彩评论