我已经部署我的django项目在pythonanywhere,DATABASES是不正确配置的错误 [英] I have deployed my django project in pythonanywhere, DATABASES is improperly configured error

查看:151
本文介绍了我已经部署我的django项目在pythonanywhere,DATABASES是不正确配置的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have deployed my django project in pythonanywhere without any databases required, I am getting the error- DATABASES is improperly configured . The link to my deployed project is -http://drchitradhawle.pythonanywhere.com/


我的setting.py文件是 -

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


推荐答案

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

Although you don't want to use database in your project but still you have to give database defination as @conrad said. So you can use sqlite3, a file based database that does not require setting up a database account and password.


将数据库设置为 -

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

现在,系统会要求您输入用于创建超级用户的密码,用户名和电子邮件数据库。
和它的一切!

Now you will be asked for password, username and email-Id for creating superuser for database. And its all done!

这篇关于我已经部署我的django项目在pythonanywhere,DATABASES是不正确配置的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆