How can I search for time with time zone if I store time by utc
For the purpose of the example I have inserted datetime ‘2021-06-19T16:20:00+01:00’
It’s saved as ‘2021-06-19T15:20:00’
And if I want to search for him I have to search MeteorologicalData.objects.filter(datetime__time=“15:20:00”)
but if i want to search as MeteorologicalData.objects.filter(datetime__time=“16:20:00+01:00”) It does not return anything
Rather than passing the value to the query as a string, convert it to a datetime (or time) object and use that as a parameter.
See the example in the Chaining filters section of the docs to get an idea of how to do this.
What do you mean by a more “django solution”? Django just provides an abstraction layer on top of the database. It’s the database performing these comparisons, and so you need to supply query data that the database can understand and use.
You are responding to a thread that is more than 2 years old with a question that may be about a different issue.
You’re likely to get more of a response if you open a new topic for this, along with providing more details about the problem you’re facing. Include the complete traceback along with any error messages you are receiving.