Parámetros para .filter()
>>> lb = Book.objects.filter(id=1)
>>> lb = Book.objects.filter(author=’J.R.R. Tolkien’)
>>> lb = Book.objects.filter(id__gt=5) # greaterthan >
>>> lb = Book.objects.filter(id__lt=5) # lowerthan <
>>> lb = Book.objects.filter(id__gte=5) # greaterthanequal >=
>>> lb = Book.objects.filter(id__lte=1) # lowerthanequal <=
>>> lb = Book.objects.filter(title__contains=”Kill”)
>>> lb = Book.objects.filter(title__startswith=”The”)
>>> loan = Loan.objects.filter(loan_date__year=2022)
>>> loan = Loan.objects.filter(book_id__title='Don Quijote')
[Cuando es un campo con una relación busca en la tabla relacionada
hasta que encuentra la etiqueta en cuestión]
Comando para ver la consulta SQL
>>> book = Book.objects.filter(id__gt=5)
>>> book.query.__str__()
'SELECT "biblio_book"."id", "biblio_book"."title", "biblio_book"."author", "biblio_book"."genre_id", "biblio_book"."year", "biblio_book"."publisher_id" FROM "biblio_book" WHERE "biblio_book"."id" > 5'