Return 400 if date format is invalid

This commit is contained in:
Paweł Jastrzębski 2022-04-26 10:13:52 +02:00
parent b87b158aab
commit ca97453c3e

View File

@ -29,8 +29,12 @@ class DashboardApiView(ApiTokenRequiredMixin, DateRangeMixin, View):
services = services.filter(uuid=uuid) services = services.filter(uuid=uuid)
basic = request.GET.get('basic', '0').lower() in ('1', 'true') basic = request.GET.get('basic', '0').lower() in ('1', 'true')
start = self.get_start_date() try:
end = self.get_end_date() start = self.get_start_date()
end = self.get_end_date()
except ValueError:
return JsonResponse(status=400, data={'error': 'Invalid date format'})
services_data = [ services_data = [
{ {
'name': s.name, 'name': s.name,