每当我尝试EmbeddedField
使用 Djongo 在 Django 中创建一个时,我都会收到以下错误消息。我尝试了网络上建议的所有内容。但我完全被困在这里,需要帮助来克服这个问题。只要我尝试migrate
或尝试runserver
它就会引发此错误。我一使用EmbeddedField
. 我没有修改 manage.py 文件。
错误信息
djongo django.core.expceptions.AppRegistryNotReady: Models aren't loaded yet.
模型.py
from djongo import models
class ClientRepresentation(models.Model):
client_main_contact = models.CharField(max_length=100)
client_stand_in_contact = models.CharField(max_length=100)
class Meta:
abstract = True
class User(models.Model):
client_name = models.CharField(max_length=100)
client_location = models.CharField(max_length=100)
client_representation = models.EmbeddedField(
model_container=ClientRepresentation
# null=True
)
objects = models.DjongoManager()
def __str__(self):
return self.client_name
设置.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# REST Framework API
'rest_framework',
# Own Apps
'usr'
]
管理.py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djongotest.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()