开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜