From 61b72977aa3f57cb1c5f299ef95b205a92056e27 Mon Sep 17 00:00:00 2001 From: ellinnyk Date: Wed, 21 Jun 2017 00:01:15 +0300 Subject: [PATCH] Changed settings.py --- .gitignore | 4 +- pybursa/local_settings_example.py | 119 ++++++++++++++++++++++++++++++ pybursa/settings.py | 8 ++ 3 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 pybursa/local_settings_example.py diff --git a/.gitignore b/.gitignore index bdc50705..01a801e1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ .idea/ __pycache__ venv/ -courses_logger.log -students_logger.log +*.log +local_settings.py \ No newline at end of file diff --git a/pybursa/local_settings_example.py b/pybursa/local_settings_example.py new file mode 100644 index 00000000..c12622f7 --- /dev/null +++ b/pybursa/local_settings_example.py @@ -0,0 +1,119 @@ +""" +Django settings for pybursa project. + +Generated by 'django-admin startproject' using Django 1.10. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.10/ref/settings/ +""" + +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.10/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 's0+w5fxsnw9b42cayh7=!--%x(-6nz)r04d&m#mjiwcjjcos*a' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = [] + + +# Application definition + +EMAIL_HOST = "127.0.0.1" +EMAIL_PORT = "1025" +ADMINS = [('John', 'john@example.com'), ('Mary', 'mary@example.com')] +WSGI_APPLICATION = 'pybursa.wsgi.application' + +LOGGING = { + 'version': 1, + #'disable_existing_loggers': False, + 'formatters': { + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(module)s %(funcName)s %(message)s' + }, + 'simple': { + 'format': '%(levelname)s %(message)s' + }, + }, + 'handlers': { + 'file1': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'formatter': 'simple', + 'filename': os.path.join(BASE_DIR,'courses_logger.log'), + }, + 'file2': { + 'level': 'WARNING', + 'class': 'logging.FileHandler', + 'formatter': 'verbose', + 'filename': os.path.join(BASE_DIR,'students_logger.log'), + }, + }, + 'loggers': { + 'pybursa.courses': { + 'handlers': ['file1'], + 'level': 'DEBUG', + #'propagate': True, + }, + 'pybursa.students': { + 'handlers': ['file2'], + 'level': 'WARNING', + #'propagate': True, + }, + }, +} + +# Database +# https://docs.djangoproject.com/en/1.10/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.10/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.10/topics/i18n/ + + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.10/howto/static-files/ + +STATIC_URL = '/static/' +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "static"), + '/static/pybursa/', +] diff --git a/pybursa/settings.py b/pybursa/settings.py index 9755a953..f0a67ff7 100644 --- a/pybursa/settings.py +++ b/pybursa/settings.py @@ -167,7 +167,15 @@ # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' +STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), '/static/pybursa/', ] +try: + + from local_settings import * + +except ImportError: + + print(“Warning! local_settings are not defined!”)