django-timezone-field获取错误unicode对象没有属性区域 [英] django-timezone-field gets error unicode object has no attribute zone

查看:276
本文介绍了django-timezone-field获取错误unicode对象没有属性区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在django中使用django-timezone-field的一个模型对象进行迁移1.7

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

我在这里找到一个解决方案: https://github.com/mfogel/django-timezone-field/issues/12

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

我安装了解决这个问题的django-time-field的分叉版本: 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

我现在得到错误: unicode对象没有属性区域'unicode'对象没有属性'localize'

我正在调用这个字段: timezone.activate(customer.time_zone.zone)

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

我的模型看起来像:

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?

推荐答案

这个fork修复它,似乎是唯一可以与django一起使用的版本1.7 https://github.com/anhtran/django-timezone-field

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

这篇关于django-timezone-field获取错误unicode对象没有属性区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆