Re: Difference in datetime with timezone

2022-03-30 Thread Andrés Alvarez
Thanks Anthony, I didn't know that pytz is deprecated. Now with zoneinfo is working. Regards, Andres. El miércoles, 30 de marzo de 2022 a la(s) 03:02:56 UTC-4, Antonis Christofides escribió: > Hi, > > not what you asked, but > > from settings import TIME_ZONE > > is an error. It happens to

Re: Difference in datetime with timezone

2022-03-30 Thread Antonis Christofides
Hi, not what you asked, but     from settings import TIME_ZONE is an error. It happens to work in this case, but generally you should write     from django.conf import settings and then use "settings.TIME_ZONE". In Django, "settings" isn't a module, it's an object. Django has some logic when

Re: Difference in datetime with timezone

2022-03-29 Thread Andrés Alvarez
I need to save some fields in my database in the format YYY-MM-MM 00:00:00+00. So I decide to do this: # setting.py TIME_ZONE = 'America/Mexico_City' USE_I18N = True USE_L10N = True USE_TZ = True # models.py class Program(models.Model): objects = models.Manager() objects_custom = Program

Re: Difference in datetime with timezone

2022-03-28 Thread Antonis Christofides
Hello, 1. Please copy your code exactly. Is it really "pytz.timezone(TIME_ZONE)"? Or is it "pytz.timezone(*settings.*TIME_ZONE)"? If it is the first one, please include the definition or importing of TIME_ZONE. 2. Please pretty-print your dictionary. You can use pprint for that. If it do

Difference in datetime with timezone

2022-03-28 Thread Andrés Alvarez
I need to save some fields in my database in the format YYY-MM-MM 00:00:00+00. So I decide to do this: field_to_save = datetime.combine(date_to_save, time.min, pytz.timezone(TIME_ZONE)) in settings.py I have: TIME_ZONE = 'America/Mexico_City' USE_I18N = True USE_L10N = True USE_TZ = True My mode