5

I use django filters backend along with Django rest for building a rest api. At certain endpoints the user can filter the request by datetime so this for example

/api/api_endpoint_x/?time_start=2015-11-20 11:22:15.160983

would form a valid request. Using Django's timezone support with USE_TZ=True all incoming datetime requests are being treated as being in end user's local time. For example if that request is coming from Berlin then the filtering will happen upon 2015-11-20 10:22:15.160983 since Berlin time is GMT+1. Is there a way to hardcode a timezone in the request so that the filtering mechanism would make use of the explicitly specified timezone?

I know I can manually inspect the query parameters and make sense out of those and then perform the filtering, but I am investigating the possibility that this functionality is already implemented inside django-filter.

For example can I use something like that

/api/api_endpoint_x/?time_start=2015-11-20 11:22:15.160983+00:00

?

LetsPlayYahtzee
  • 7,161
  • 12
  • 41
  • 65

0 Answers0