【问题标题】:django google calendar API and south freeze issuedjango google calendar API 和南冻结问题
【发布时间】:2015-02-20 08:04:12
【问题描述】:

我正在尝试使用 Google API django client lib。为了存储我的网络应用程序的每个用户的凭据,设置了一个 Credentials 模型:

from oauth2client.django_orm import CredentialsField
class CredentialsModel(models.Model):
  id = models.ForeignKey(User, primary_key=True)
  credential = CredentialsField()

但是,在尝试使用 South 迁移添加此模型时,我得到:

Cannot freeze field 'google.credentialsmodel.credential'
(this field has class oauth2client.django_orm.CredentialsField)

South cannot introspect some fields; this is probably because they are custom
fields. If they worked in 0.6 or below, this is because we have removed the
models parser (it often broke things).
To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork

我阅读了链接的文档,但我不太清楚如何解决这个问题。如何编写自省规则?或者我该如何解决这个问题以简单地添加带有这个时髦字段的模型?

【问题讨论】:

    标签: django google-api google-oauth django-south


    【解决方案1】:

    您需要在模型声明之前添加这些行:

    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^oauth2client\.django_orm\.CredentialsField"])
    

    这将允许 South 了解 oauth2client.django_orm.CredentialField 并使用其父类定义的自省规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多