Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
development:python:django:models [2021/01/12 11:25] kalenpw |
development:python:django:models [2021/06/29 15:18] (current) kalenpw |
||
---|---|---|---|
Line 17: | Line 17: | ||
print(posts) # now the query actually runs | print(posts) # now the query actually runs | ||
</ | </ | ||
+ | |||
+ | %%__%% filters for queries | ||
+ | <code python> | ||
+ | # use a __ (dunder) after a field name to access different forms of it ie | ||
+ | posts = Post.objects.filter(title=" | ||
+ | posts = Post.objects.filter(title__contains=" | ||
+ | posts = Post.objects.filter(title__startswith=" | ||
+ | posts = Post.objects.filter(pub_date__year=2020) # can also use month, day | ||
+ | </ | ||
+ | |||
+ | ---- |