我已经在python任何地方部署了我的django项目,数据库配置不正确错误



我已经在python任何地方部署了我的django项目,不需要任何数据库,我收到错误 - 数据库配置不正确。指向我已部署项目的链接是 -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/'

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

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

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

将数据库设置设置为 -

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

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

 python ./manage.py syncdb

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

相关内容

  • 没有找到相关文章

最新更新