[Solved]-Django detecting redundant migrations repetitively


You could try using an existing package that will allow you to use a time zone directly as a model field.


class MyModel(models.Model):
    timezone1 = TimeZoneField(default='Europe/London') # defaults supported


Try to copy the plain list of timezones from pytz to your project, so you are sure that choices does not depends from a third party


Your timezones are probably coming out in different orders on different runs. Try

import pytz
for time_zone in pytz.common_timezones:
    TIMEZONE_CHOICES += ((time_zone, time_zone),)
TIMEZONE_CHOICES = sorted(TIMEZONE_CHOICES) # sort list to make it consistent

Also–a minor nit since this only runs at startup–but building up a big tuple with repeated concatenation is probably a lot more expensive than this

import pytz
TIMEZONE_CHOICES = sorted((tz,tz) for tz in pytz.common_timezones)

Leave a comment