0

I have a django-admin command which is handling message sending to different users in different countries.

Each user should get the message at the same date - according to their local timezone.

For example: a user in Paris should get a message every Monday at 10 am (Paris time), and a user in NY should get a message every Monday at 10 am (NY time). What happens is that they both get the message at Monday 10 am GMT.

I can't use the user's browser local timezone, because its a script running independently in my server. Instead, I want to send the message according to a TZ stored in my DB for each users preferences.

How can I send the message according to each user's TZ in my "handle" function?

I was trying to use the "django.utils.timezone.activate" but I am not really sure how to make it work

  • Does [this](https://docs.djangoproject.com/en/4.1/topics/i18n/timezones/) help? – JDODER Nov 22 '22 at 07:35
  • Thanks. Not directly, but now I understand that the django.utils.timezone is taking its timezone from the user's browser - which I don't have here because its an internal django-admin command. I have solved the problem by using the django.utils.timezone for fields saved to the DB, and datetime.datetime with pytz for checking the user's timezone by a field I saved this user. – Naftali Shtern Nov 22 '22 at 10:48

0 Answers0