3👍
From the docs
When support for time zones is enabled, Django stores datetime
information in UTC in the database, uses time-zone-aware datetime
objects internally, and translates them to the end user’s time zone in
templates and forms.
So when you save time in database it is stored in UTC automatically by Django. When you render this time in templates or forms, it is automatically converted by Django to user’s timeozone or default timezone (TIME_ZONE = 'Europe/Paris'
) from your settings.
And this is valid for Django 1.4 and above.
To answer your questions:
Django converts the datetime to UTC, but not sure if it’s a good thing.
It is a good thing as it provides consistency, you now that all of your datetime values stored in the database are in UTC. So any time or timezone manipulation will be very easy against an approach where you will have to consider timezone for each of your record.
Am I not losing some data in the process? How to know that data
is related to the Paris timezone this way?
Why is it important for you to know in which timezone time was entered? Isn’t it enough to display time in desired timezone (Django will automatically do this and convert from UTC to your timezone). If it is important to store timezone info then you need to store it in a separate Char
type field in the model.
Here, the datetime is not converted, and the real timezone info
(Paris) is stored into the datetime. I thought is was better, but
after some searches, no one seems to process this way. Am I missing
something?
Again, when Django does this for you why would you want to do it yourself? That is why no one does this way. Plus it is a good practice to store time in standard UTC time for it to be easily convertible to any other zone.