django-timezone-field gets error unicode object ha

2019-09-17 07:11发布

问题:

I was not able to do a migration on one of my model objects that use django-timezone-field in django 1.7

I found a solution here: https://github.com/mfogel/django-timezone-field/issues/12

I installed the forked version of django-time-field which fixed this problem: https://github.com/mfogel/django-timezone-field/issues/12

I now get the error: unicode object has no attribute zone and 'unicode' object has no attribute 'localize'

I am calling the field like this: timezone.activate(customer.time_zone.zone)

My model looks like:

from timezone_field import TimeZoneField

class Customer(models.Model):
    user = models.OneToOneField(User, related_name="customer")
    time_zone = TimeZoneField()

If this fork is no good, how can I migrate? Is there any other solution besides time zone field?

回答1:

This fork fixed it and seems to be the only version that works with django 1.7 https://github.com/anhtran/django-timezone-field