我正在使用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)
先谢谢
答案 0 :(得分:0)
您是否在模型的 init .py中导入了所有模型?需要导入模型“ init .py”中的所有模型,如this answer.中所示。如果未导入, django-extensions 将无法获取所有模型。