Q Object
from django.db.models import Q
You can use the Q object from django.db.models to combine multiple conditions into a single filter. Here’s how you can refactor your code to use Q:
expired_users = ( AtsUser.objects.active() .filter( Q(last_pq_approved_on__date__lte=just_expired) & Q(last_pq_approved_on__date__gt=deactivation_time) ) )
Dumping (or backing up) `pg_dump -U zanbato zanbato > ~/backup.pgdump
Flushing the Database
dropdb -U zanbato zanbato createdb -U zanbato zanbato
psql -U zanbato zanbato < ~/backup.pgdump python manage.py migrate