Created
July 24, 2025 21:07
-
-
Save felipebastosweb/32c9ff21283da320af209408e2561c6f to your computer and use it in GitHub Desktop.
Dica de Filtro no Django ORM por intervalo de datas
This file contains hidden or 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
from datetime import datetime, timedelta | |
from django.utils import timezone | |
# Calculando a data de 15 dias atrás | |
data_inicio = timezone.now() - timedelta(days=15) | |
data_fim = timezone.now() | |
# Filtrando e ordenando os registros | |
pastas_modificadas = PastaAluno.objects.filter( | |
data_modificacao__range=(data_inicio, data_fim) | |
).order_by('data_modificacao') | |
# Exibindo as localizações das pastas encontradas | |
for pasta in pastas_modificadas: | |
print(pasta.localizacao) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment