# Django settings for mysite project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'django', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': '123', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Asia/Chongqing'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'zh-cn'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'j#z!#ciaw-gxgctvik7!5k^e-40h*g8bnzwag$txk^&8xexxs*'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
"""
django.template.loaders.filesystem.Loader : 这个加载器根据 TEMPLATE_DIRS 的设置从文件系统加载模板。它默认是可用的。
"""
'django.template.loaders.filesystem.Loader',
"""
django.template.loaders.app_directories.Loader : 这个加 载器从文件系统上的Django应用中加载模板。 对 INSTALLED_APPS 中的每个应用,这个加载器会查找templates 子目录。 如果这个目录存在,Django就在那里寻找模板。
"""
'django.template.loaders.app_directories.Loader',
"""
django.template.loaders.eggs.Loader : 这个加载器类似 app_directories ,只不过它从Python eggs而不是文件系统中加载模板。 这个加载器默认被禁用;如果你使用eggs来发布你的应用,那么你就需要启用它。 Python eggs可以将Python代码压缩到一个文件中
"""
'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'mysite.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/home/sislcb/jack/django/mysite/templates',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'mysite.servers',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
[sislcb@gm_247 mysite]$ cat settings.py
# Django settings for mysite project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'django', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'youease', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Asia/Chongqing'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'zh-cn'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'j#z!#ciaw-gxgctvik7!5k^e-40h*g8bnzwag$txk^&8xexxs*'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'mysite.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/home/sislcb/jack/django/mysite/templates',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'mysite.servers',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
相关推荐
其实就是把不同功能的文件放到不同目录下,然后通过代码代用将各个模块组合起来。这样的好处就是松耦合。具体各模块的作用通过创建工程来介绍
首先setting.py配置文件中添加静态文件的路径: STATICFILES_DIRS = [ os.path.join(BASE_DIR, “statics”),] statices为你所建立的存放静态文件的文件夹名 然后进行引用。 1、html 文件中通过 /static/资源名的...
在Django框架中,`settings` 文件是项目的核心配置,它定义了项目的各种行为和特性。下面我们将深入探讨一些最佳实践和常见配置。 1. **DJANGO_SETTINGS_MODULE**: 这是一个环境变量,用于指示Python查找settings...
4.在setting文件中添加数据库配置 5.进cmd进行数据库连接 6.定义模型 7. 安装模型 setting文件,INSTALLED_APPS中添加对应app名称 8. 注册model到admin 9.创建表格 10.同步数据 11.创建超级管理员 12.运行...
解决方法: 1.首先你需要在自己的app下面创建2个目录 ... 您可能感兴趣的文章:django 解决自定义序列化返回处理数据为null的问题django queryset 去重 .distinct()说明django的403/404/500错误自定义页面的配置方式
这个库的版本是5.1.2.2,它以tar.gz格式提供,这是常见的开源软件打包方式,通常包含源代码、README文件、LICENSE文件以及安装和配置所需的其他文档。 `django-tempus-dominus`是一个与Python Django框架集成的时间...
在Django框架中,连接Oracle数据库需要在项目的`settings.py`配置文件中进行设置。首先,确保你的系统已经安装了Django和Oracle数据库驱动,例如cx_Oracle。接下来,我们详细讲解配置过程。 1. **配置DATABASES变量...
这是用pycharm软件编写的基于django的学生信息管理系统,含有MySQL数据库,数据库得自己配,具体配置方法需要百度,数据库表配置文件在models,数据库配置文件在setting里database,有问题可以评论
有一些解决方案是利用配置文件是py文件这个特性,在配置里面写一些 if-else 来达到区分线上配置与开发配置的目的。但是当项目较为复杂的时候,这样写的可读性十分差,而且可能产生一些条件判定的BUG。 所以更加...
2.在配置文件setting.py INSTALLED_APP 中添加新创建的应用stu 3.配置urls,分别在test\urls 和子路由stu\urls 中 #test\urls urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^student/',include('stu...
在Django框架中,`settings.py`文件是一个至关重要的组件,它存储了项目的各种配置信息。这个文件定义了你的Django应用如何与数据库交互、如何处理时间、国际化、静态文件和应用程序的安装等核心功能。以下是对`...
2. **修改配置文件:**如果使用的是 Service Name,应确保配置文件中的 NAME 参数符合格式 `host:port/service_name`。例如: ```python 'default': { 'ENGINE': 'django.db.backends.oracle', 'NAME': 'host.db...
基于Django+python开发的B2C分布式生鲜商城源码-毕设项目.zip 【说明】 技术栈 语言:Python3.6.8 (Django==2.1.5) ...setting文件配置好mysql数据库 填入REDIS_CONFIG的配置信息 生成迁移文件 python manager
bin目录是在linux环境中使用Nginx+Gunicorn+virtualenv+supervisor来部署的脚本和Nginx配置文件.可以参考我的文章: DjangoBlog部署教程 有详细的部署介绍. 运行 修改DjangoBlog/setting.py 修改数据库配置,如下...
在Django项目中,配置通常写在settings.py文件中,而`django-constance` 提供了一种更加灵活的方式,使得这些配置可以在数据库、Redis或其他后端存储中动态管理。 **主要特性:** 1. **实时更新配置**:`django-...
- 第一种,生成的配置文件目录与项目名一致 django-admin startproject projectname - 第二种:创建的配置文件目录是config mkdir projectname && cd projectname django-admin startproject config . #### ...
为了支持这种场景,Django提供了一种灵活的方式来进行配置。本文将详细介绍如何在Django项目中配置多个数据库,并利用原生SQL进行数据查询与更新。 #### 设置多个数据库连接 首先,在`settings.py`文件中定义多个...