ubuntu中的Python/django环境错误[关闭]

Posted

技术标签:

【中文标题】ubuntu中的Python/django环境错误[关闭]【英文标题】:Python/django environment error in ubuntu [closed] 【发布时间】:2016-10-24 04:08:44 【问题描述】:

环境:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/

Django Version: 1.6.1
Python Version: 2.7.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'south']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

追溯:

File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in wrapper
  215.                 return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
  197.                 return self.login(request)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in login
  330.         return login(request, **defaults)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  75.             return view(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/contrib/auth/views.py" in login
  49.     current_site = get_current_site(request)
File "/usr/lib/python2.7/dist-packages/django/contrib/sites/models.py" in get_current_site
  103.         current_site = Site.objects.get_current()
File "/usr/lib/python2.7/dist-packages/django/contrib/sites/models.py" in get_current
  43.             raise ImproperlyConfigured("You're using the Django \"sites framework\" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.")

Exception Type: ImproperlyConfigured at /admin/
Exception Value: You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.

【问题讨论】:

我对 Django 一无所知,但是您是否尝试过在数据库中创建站点并设置 SITE_ID 设置来修复此错误? 发布回溯不是问题 - 无论如何,异常消息包含解决问题所需的所有信息。 【参考方案1】:

将 settings.py 中的 site_id 设置为 1 或从已安装的应用程序中注释掉此语句: 'django.contrib.sites',

【讨论】:

以上是关于ubuntu中的Python/django环境错误[关闭]的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu+apache+python+django部署

在 python django 服务 ubuntu 中安装 reportLab

Python3 + django2.0 + apache2 + ubuntu14部署网站上线

在 Python Django 中加载 Mysqldb 模块时出错

视图中的错误 python django

Python+Django+Ansible Playbook自动化运维项目实战