Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JorgeMichelena
Created September 19, 2022 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JorgeMichelena/c6cadba194cfff4cdde7ed3745acb697 to your computer and use it in GitHub Desktop.
Save JorgeMichelena/c6cadba194cfff4cdde7ed3745acb697 to your computer and use it in GitHub Desktop.
from django.utils import timezone
from dateutil.relativedelta import relativedelta
# Calculate the date to get those users who have a date_of_birth value
# less than it, to make sure they are 21 years old or older
max_datetime = timezone.now() - relativedelta(years=21)
queryset = q1.union(User.objects.filter(date_of_birth__lte=max_datetime))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment