Created
April 7, 2019 00:38
-
-
Save valerybriz/dda05ed09e91ec1e76b49573dc180565 to your computer and use it in GitHub Desktop.
cached and not cached queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the query filtering users with email myemail@gmail.com | |
users = User.objects.get(email="myemail@gmail.com") | |
users.name # Hit the database and retrive the name value | |
users.name # cached version, no database access | |
# Create the query filtering teams named tigers | |
team = Team.objects.get(name="tigers") | |
team.users.all() # query performed | |
team.users.all() # query performed again |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment