我正在将一个Django 1.10项目部署到一个带有Apache和mod_wsgi的Ubuntu服务器上。我遇到了以下无法解决的500错误:
RuntimeError: Model class django.contrib.contenttypes.models.ContentType没有声明一个明确的app_label,并且不在INSTALLED_APPS中的应用程序中。
settings.py中的installed_apps:
RuntimeError: Model class django.contrib.contenttypes.models.ContentType没有声明一个明确的app_label,并且不在INSTALLED_APPS中的应用程序中。
settings.py中的installed_apps:
INSTALLED_APPS = [
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
]
wsgi.py:
sys.path.append('/home/x_dashboard/x_dashboard/')
activate_this = os.path.expanduser("/home/x_dashboard/.venv/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
os.environ['PYTHON_EGG_CACHE'] = '/home/x_dashboard/x_dashboard/.python-egg'
os.environ['DJANGO_SETTINGS_MODULE'] = 'x_dashboard.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Apache配置:
<VirtualHost *:80>
#ServerName example.com
#ServerAlias www.example.com
#ServerAdmin username@example.com
DocumentRoot /home/x_dashboard/x_dashboard/
#ErrorLog /var/www/html/example.com/logs/error.log
#CustomLog /var/www/html/example.com/logs/access.log combined
WSGIScriptAlias / /home/x_dashboard/x_dashboard/x_dashboard/wsgi_local.py
#Alias /robots.txt /var/www/html/example.com/public_html/robots.txt
#Alias /favicon.ico /var/www/html/example.com/public_html/favicon.ico
#Alias /images /var/www/html/example.com/public_html/images
Alias /static /var/www/x_dashboard/static
<Directory /home/x_dashboard/x_dashboard/x_dashboard/>
<Files wsgi.py>
Order deny,allow
Allow from all
Require all granted
</Files>
</Directory>
</VirtualHost>
Django文档指出,对于不属于已定义在installed_apps中的应用程序的模型,需要提供app_label。然而,'django.contrib.contenttypes' 已经被定义在installed_apps中。
感谢任何帮助。