【问题标题】:django-simple-history cannot import name error for model import in management commanddjango-simple-history cannot import name error for model import in management command
【发布时间】:2015-08-12 03:20:09
【问题描述】:

我正在使用 django-simple-history 来维护每个模型的历史记录。现在,当我在管理命令中导入模型时,它会给出

导入错误“找不到导入名称'ModelName'”。

对此有任何帮助吗?

【问题讨论】:

  • 发布你的管理命令文件
  • from django.core.exceptions import ObjectDoesNotExist from api.v1.restaurants.models import Restaurant from api.v1.restaurants.utils import convert_to_e164 from django.core.management.base import BaseCommand import logging logger = logging.getLogger(name) import json from django.db import transaction from django.db.models import Q import random """ 相应地更改逻辑在 rating """ class Command(BaseCommand): def handle (self, *args, **options):
  • "api.v1.restaurants.models import Restaurant" 这是导致错误的行。名称匹配。如果我点击它就会进入模型
  • 我将 django-simple-history 降级到 1.2.0 并开始工作。虽然我使用的是 django 1.6.7,但对解决方案不满意

标签: python django python-2.7 django-models


【解决方案1】:

跟踪模型的历史并修复您使用此代码的问题。

pip install django-simple-history

【讨论】:

    猜你喜欢
    • 2022-12-28
    • 2020-11-30
    • 1970-01-01
    • 2022-12-28
    • 2014-05-10
    • 1970-01-01
    • 2015-03-07
    • 2017-06-03
    • 2019-01-06
    相关资源
    最近更新 更多