django-timezone-field gets error unicode object has no attribute zone

丶灬走出姿态 提交于 2019-12-13 04:16:52

问题


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



来源:https://stackoverflow.com/questions/25854783/django-timezone-field-gets-error-unicode-object-has-no-attribute-zone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!