This would be a queryset
active_event_object = VActiveEvent.objects.filter(calendar_id=date_today)
So I could do something like this to check if the queryset returned anything;
def calendar_criteria(request):
date_today = timezone.now()
active_event_object = VActiveEvent.objects.filter(calendar_id=date_today)
context = {
'vae_object': active_event_object
}
if active_event_object.exists():
template = 'view2.html'
else:
template = 'index.html'
return render(request, template, context)
But this would be a dict, right?
active_event_object = VActiveEvent.objects.filter(calendar_id=date_today).aggregate(Min('event_priority'))
So if I wanted to check if exists or does not exist would it truly be this simple or is there a better alternative?
if active_event_object:
not empty ...
else:
empty ...
EDIT
Testing in the Shell, it looks like you’d actually want to look at;
active_event_object['event_priority__min']
def calendar_criteria(request):
date_today = timezone.now()
active_event_object = VActiveEvent.objects.filter(calendar_id=date_today).aggregate(Min('event_priority'))
context = {
'vae_object': active_event_object
}
if not active_event_object['event_priority__min']:
template = 'index.html'
else:
template = 'view2.html'
return render(request, template, context)