Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
development:python:django:models [2021/01/12 11:30]
kalenpw
development:python:django:models [2021/06/29 15:18] (current)
kalenpw
Line 18: Line 18:
 </code> </code>
  
 +%%__%% filters for queries
 <code python> <code python>
- 
 # use a __ (dunder) after a field name to access different forms of it ie # use a __ (dunder) after a field name to access different forms of it ie
 posts = Post.objects.filter(title="A New Title") posts = Post.objects.filter(title="A New Title")
Line 26: Line 26:
 posts = Post.objects.filter(pub_date__year=2020) # can also use month, day posts = Post.objects.filter(pub_date__year=2020) # can also use month, day
 </code> </code>
 +
 +----