【发布时间】:2016-09-18 16:00:43
【问题描述】:
我是 python-django 的新手。
我在 django 中创建了一个数据库,我可以调用所有函数并正确使用它。问题是我不知道数据库是在mySql还是SQLite中。
我在终端运行了 sqlite 和 sqlite3 命令,它说程序没有安装。当我运行 MySQL 命令时,它已安装但未在 show databases 命令中显示我的数据库。
我不知道settings.py文件的变化,直接跳转到views.py文件。
我也不知道我的数据库名称。我正在发布我的settings.py 文件。谁能帮忙,我必须创建我的数据库的转储。
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')mjm**********************************0b'
# SECURITY WARNING: don't run with debug turned on in production!
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',
'law_app',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'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 = 'TheLawyerApp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'TheLawyerApp.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/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.9/howto/static-files/
STATIC_URL = '/static/'
【问题讨论】:
-
'ENGINE': 'django.db.backends.sqlite3'sqlite3 似乎......顺便说一句,sqlite3 预装在 mac 上 -
@HugoHonorem 我正在使用 ubuntu.. 14.04
-
您不应该使用
SECURUTY_KEY在线发布您的配置!既然您这样做了,请确保如果您的安装实际上在某个地方在线,请务必更改它。 -
@mata 非常感谢!我已经更新了我的问题。
-
@PrakharSrivastava - 现在没有什么意义了,它已经被泄露了。确保更改应用程序中的安全密钥,然后就没有关系了。
标签: python mysql django sqlite