我已经在pythonanywhere中部署了我的django项目,DATABASES是错误配置的错误

时间:2015-03-09 16:44:13

标签: django database python-2.7 deployment pythonanywhere

我已经在pythonanywhere中部署了我的django项目而没有任何数据库,我收到错误 - DATABASES配置不正确。我部署的项目的链接是 - http://drchitradhawle.pythonanywhere.com/

  

我的setting.py文件是 -

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fi+9_egiio(7l6xvbgk%o=!k(ktn3!ywhc4+p_6^57j4yvl0tp'


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'webpage',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'website.urls'

WSGI_APPLICATION = 'website.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_ROOT = "/home/DrChitraDhawle/website/webpage/static"
STATIC_URL = '/static/'
STATICFILES_DIR = (
    ('assets', '/home/DrChitraDhawle/website/webpage'),
    )
#
#STATICFILES_DIR = [os.path.join(BASE_DIR, '')]

MEDIA_URL = 'http://localhost:8085/media/'

2 个答案:

答案 0 :(得分:3)

Django需要一个数据库来存储会话/ cookie信息等信息。因此,即使您不将数据库用于自己的网站,也需要一个。

幸运的是,只需使用默认的sqlite设置,然后运行./manage.py syncdb就足以让一切正常工作。

答案 1 :(得分:0)

虽然你不想在你的项目中使用数据库,但仍然必须给出数据库定义,因为@conrad说。因此,您可以使用sqlite3,这是一个基于文件的数据库,不需要设置数据库帐户和密码。

  

将数据库设置设置为 -

 DATABASES = {
              'default': {
                   'ENGINE': 'django.db.backends.sqlite3',
                   'NAME': '/home/<username>/<ProjectName>/db.sqlite',
                   'USER': '',
                   'PASSWORD': '',
                   'HOST': '',
                   'PORT': ''
               }
          }
  

之后在控制台中运行以下命令 -

 python ./manage.py syncdb

现在,系统会要求您输入密码,用户名和电子邮件ID,以便为数据库创建超级用户。 一切都完成了!