[Solved]-Django detecting redundant migrations repetitively

1👍

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

https://pypi.python.org/pypi/django-timezone-field/

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

1👍

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

0👍

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

import pytz
TIMEZONE_CHOICES = ()
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