【问题标题】:Error: django.core.exceptions.ImproperlyConfigured错误:django.core.exceptions.ImproperlyConfigured
【发布时间】:2016-07-16 15:07:47
【问题描述】:

我正在使用 django-extensions 来表示图形模型。 运行此命令时:

 $ ./manage.py graph_models -a -g -o my.png

错误:

django.core.exceptions.ImproperlyConfigured:带有标签大括号的应用缺少 models.py 模块。

我的项目结构:

Project
        app1
            models
                 abc.py
                 xyz.py
                 __init__.py
             urls.py
             admin.py
             views.py
             __init__.py
       app2
            models
                 abc1.py
                 xyz1.py
                 __init__.py
             urls.py
             admin.py
             views.py
             __init__.py

我的模型/abc.py:

class Abc(AbstractBaseUser):

MALE = "M"
FEMALE = "F"

SEX_CHOICES = [
    (MALE, "Male"),
    (FEMALE, "Female"),
]

SEX_CHOICES_AND_BLANK = [('', 'Select Gender')] + SEX_CHOICES


email = models.EmailField(_('Email Address'), max_length=70, unique=True)
first_name = models.CharField(_('First Name'), max_length=30)
last_name = models.CharField(_('Last Name'), max_length=30)
username = models.CharField(_('username'), max_length=70, unique=True)
gender = models.CharField(_("Gender"), max_length=1, choices=SEX_CHOICES, blank=True)
contact_number = models.CharField(
    _("Contact Number"),
    max_length=15,
    blank=True,
    validators=[
        RegexValidator(r'^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$')
    ])

# Profile extras
image = ImageFileField(upload_to=get_upload_file_name, blank=True, default='user-default.png')
about = models.TextField(_("about me"), blank=True)

提前致谢

【问题讨论】:

  • 您使用的是哪个版本的 Django? braces 来自哪里?使用 app1app2 之类的名称而不是您的实际代码会使它更加混乱。

标签: django pydot django-extensions


【解决方案1】:

您是否在模型的 init.py 中导入了所有模型?需要导入模型的 init.py 中的所有模型,如 this answer. 中给出的。如果不导入,django-extensions将无法获取所有模型。

【讨论】:

  • 是的..我已经在models'init.py文件中导入了所有模型。
  • 我已经解决了这个问题,但是运行这个命令时我得到了一个空文件
  • 你能用解决方案更新问题吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-11-24
  • 2015-05-25
  • 2021-11-24
  • 2020-05-13
  • 2013-03-13
  • 2016-05-02
  • 1970-01-01
相关资源
最近更新 更多