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.

Answers


Django relation fields are implemented as descriptors.


Need Your Help

Python Email table from MYSQL

python mysql email

I am trying to get the results of a MYSQL query into the body of an email and also as a csv or xls attachment.

Using double quotes in a T-SQL script fails in SQLCMD, but not SSMO

sql-server tsql sqlcmd

Executing the following script via sqlcmd fails. However, executing it via ssmo or SQL Server Management Studio works.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.