I have an important question. I understand Django saves data in "localtime", that is, UTC for my international app. So, if a user creates an "Event" with startdate (datetime object) 18:00, it will be 18:00 UTC. However, the user lives in Spain (UTC+1), so I store the timezone ("Europe/Madrid") in a different field. When I render it in the html, it will show the UTC time (but the user lives in UTC+1). Then, if I want to convert the time to a visiting user from Spain, I use the timezone
tag to convert the datetime to Spain ... and now it will show 19:00.
{% if logged_user_profile.timezone %}
{% timezone logged_user_profile.timezone %}
<p class="text-muted font-weight-bold">
{{ event.date_start|date:"h:i A" }} ({{ logged_user_profile.timezone }}
</p>
{% endtimezone %}
{% else %}
<p class="text-muted font-weight-bold">
{{ event.date_start|date:"h:i A" }} ({{ owner_profile.timezone }})
</p>
{% endif %}
The Spain case is only an example. I guess my question is broad, which is the best way to deal with timezones in django. I need to store the datetime of an event and show it to visiting users in their localtime, if the stored datetime is in UTC, it will not reflect the datetime the user that created the event had in mind when I add a timezone to it.