每当我尝试运行makemigrations或runserver时,我都会收到此错误:
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and
isn't in an application in `INSTALLED_APPS`.
但是: 这是INSTALLED_APPS -
WSGI_APPLICATION = 'mysite.wsgi.application'
import django
django.setup()
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_comments',
'django_comments_xtd',
'django.contrib.sites',
'accounts.apps.AccountsConfig',
'posts.apps.PostsConfig',
'category',
#'vote',
'tinymce',
'django_wysiwyg',
'follow',
'djrichtextfield',
'ckeditor',
#'likes',
'secretballot',
'hitcount',
#'pinax',
'pinax.likes',
#'pinax',
#'pinax_theme_bootstrap',
#'bootstrapform',
#'voting',
'actstream',
]
可能导致这种情况的原因是什么?正如您所见,它已在Installed_Apps中明确说明。
答案 0 :(得分:0)
我通过将Django降级到1.8来实现它。我觉得1.9有一些问题!
答案 1 :(得分:0)
对我来说:
UsersConfig(AppConfig)类:
name = "opercat_api.users"
verbose_name = _("Users")
适合你们:
UsersConfig(AppConfig)类:
name = "myapp.users"
verbose_name = _("Users")
对我来说:
ExcepcionesConfig(AppConfig)类:
name = 'opercat_api.excepciones'
verbose_name = 'Excepciones'
适合你们:
MyappnameConfig(AppConfig)类:
name = 'myproject.myappname'
verbose_name = 'Myappname'
当然,不要忘了检查(设置/基准)中的INSTALLED_APPS。py
我真的希望这个答案与其他答案一起对您有所帮助