Django database caching

Posted by hekevintran on Stack Overflow See other posts from Stack Overflow or by hekevintran
Published on 2010-04-05T06:33:00Z Indexed on 2010/04/05 10:03 UTC
Read the original article Hit count: 376

Filed under:
|

The object user has a foreign key relationship to address. Is there a difference between samples 1 and 2? Does sample 1 run the query multiple times? Or is the address object cached?

# Sample 1
country = user.address.country
city = user.address.city
state = user.address.state

# Sample 2
address = user.address
country = address.country
city = address.city
state = address.state

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models