我已经在 pythonanywhere 中部署了我的 django 项目,DATABASES is improperly configured 错误

I have deployed my django project in pythonanywhere, DATABASES is improperly configured error

我已经在不需要任何数据库的情况下在 pythonanywhere 中部署了我的 django 项目,但出现错误 - DATABASES 配置不正确。我部署的项目的 link 是 -http://drchitradhawle.pythonanywhere.com/

My setting.py file is-

# 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/'

Django 需要一个数据库来存储session/cookieinfo 等信息。因此,即使您不将数据库用于您自己的网站内容,您仍然需要一个。

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

虽然您不想在您的项目中使用数据库,但您仍然必须像@conrad 所说的那样提供数据库定义。所以你可以使用sqlite3,一个不需要设置数据库帐户和密码的基于文件的数据库。

Set up your database setting as -

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

After that run the below command in console -

 python ./manage.py syncdb

现在您将被要求输入密码、用户名和电子邮件 ID 来为数据库创建超级用户。 一切都完成了!