Django模型“不声明显式的app_label” [英] Django model "doesn't declare an explicit app_label"

查看:1889
本文介绍了Django模型“不声明显式的app_label”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在机智的尽头。经过十几个小时的故障排除,可能更多的是,我以为我终于开始了,但是我得到了:

 模型类django .contrib.contenttypes.models.ContentType不声明一个显式的app_label 

有很多关于这在网络上,没有解决方案已经解决了我的问题。任何建议将非常感激。



我使用的是Python 3.4和Django 1.10。



从我的设置.py:

  INSTALLED_APPS = [
'DeleteNote.apps.DeletenoteConfig',
'LibrarySync.apps .LibrarysyncConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions ',
'django.contrib.messages',
'django.contrib.staticfiles',
]

我的apps.py文件如下所示:

  from django.apps import AppConfig 


class DeletenoteConfig(AppConfig):
name ='DeleteNote'

 从django.apps导入AppConfig 


类LibrarysyncConfig(AppConfig):
name ='LibrarySync'


解决方案

您是否忘记将应用程序名称放入设置文件?
myAppNameConfig 是在apps.py上通过 .manage.py createapp myAppName 命令生成的默认类。其中 myAppName 是您的应用程序的名称。



settings.py

  INSTALLED_APPS = [
' myAppName.apps.myAppNameConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django。 contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

]



这样,设置文件就会发现你想要调用的应用程序。您可以通过添加



myAppName / apps.py



<$ p来更改apps.py文件中的更新版本$ p> class myAppNameConfig(AppConfig):
name ='myAppName'
verbose_name ='一个更好的名字'


I'm at wit's end. After a dozen hours of troubleshooting, probably more, I thought I was finally in business, but then I got:

Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label 

There is SO LITTLE info on this on the web, and no solution out there has resolved my issue. Any advice would be tremendously appreciated.

I'm using Python 3.4 and Django 1.10.

From my settings.py:

INSTALLED_APPS = [
    'DeleteNote.apps.DeletenoteConfig',
    'LibrarySync.apps.LibrarysyncConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

And my apps.py files look like this:

from django.apps import AppConfig


class DeletenoteConfig(AppConfig):
    name = 'DeleteNote'

and

from django.apps import AppConfig


class LibrarysyncConfig(AppConfig):
    name = 'LibrarySync'

解决方案

Are you missing putting in your application name into the settings file? The myAppNameConfig is the default class generated at apps.py by the .manage.py createapp myAppName command. Where myAppName is the name of your app.

settings.py

INSTALLED_APPS = [
'myAppName.apps.myAppNameConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

]

This way, the settings file finds out what you want to call your application. You can change how it looks later in the apps.py file by adding

myAppName/apps.py

class myAppNameConfig(AppConfig):
    name = 'myAppName'
    verbose_name = 'A Much Better Name'

这篇关于Django模型“不声明显式的app_label”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆