相关疑难解决方法(0)

使用南冻结时,南数据迁移'实例'错误

我有一个南数据迁移,试图根据其他模型中的数据创建新对象.在尝试为给定的"目标"模型创建新对象时,我不断获得:

Cannot assign "<ContentType: ContentType object>": "Publishing.content_type" must be a "ContentType" instance.
Run Code Online (Sandbox Code Playgroud)

当通过South冻结ORM访问时,"实例"似乎有问题,例如:

ContentType = orm['contenttypes.ContentType']
content_type_kwargs = {
    'model': ContentModel._meta.module_name, 
    'app_label': ContentModel._meta.app_label, }
content_type = ContentType.objects.get(**content_type_kwargs)

# further down

publishing_kwargs = {
    'site': Site.objects.get_current(),
    'publishing_type': publishing_type,
    'start': start,
    'content_type': content_type, 
    'object_id': content_object.id, }

publishing = orm.Publishing(**publishing_kwargs) # Produces the error above
Run Code Online (Sandbox Code Playgroud)

现在我已多次验证它content_type实际上是ContentType的一个实例 - 但不知何故django并不这么认为.

  • "冻结",南方orm版本的实例与原生django版本之间有区别吗?
  • 这可能是什么呢?

django data-migration django-south

4
推荐指数
1
解决办法
2521
查看次数

标签 统计

data-migration ×1

django ×1

django-south ×1