Django model "doesn't declare an explicit app_label"
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 the following code in
myAppName/apps.py
class myAppNameConfig(AppConfig):
name = 'myAppName'
verbose_name = 'A Much Better Name'
I get the same error and I don´t know how to figure out this problem. It took me many hours to notice that I have a init.py at the same direcory as the manage.py from django.
Before:
|-- myproject
|-- __init__.py <---
|-- manage.py
|-- myproject
|-- ...
|-- app1
|-- models.py
|-- app2
|-- models.py
After:
|-- myproject
|-- manage.py
|-- myproject
|-- ...
|-- app1
|-- models.py
|-- app2
|-- models.py
It is quite confused that you get this "doesn't declare an explicit app_label" error. But deleting this init file solved my problem.