【问题标题】:error: ContentType matching query does not exist错误:ContentType 匹配查询不存在
【发布时间】:2011-06-28 09:13:48
【问题描述】:

在 Django 1.3 中不起作用下一个示例:

尝试: object = ContentType.objects.get(model="test").get_object_for_this_type(pk=object_id) 除了: 提出Http404

为什么?

【问题讨论】:

  • 如果你没有盲目地接受异常,错误信息会告诉你原因。

标签: django


【解决方案1】:

要让 django 为您的所有模型创建 ContentType,您应该运行

python manage.py syncdb

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-27
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-25
    • 2011-09-25
    • 2013-07-22
    相关资源
    最近更新 更多