Added database credentials and security check for db password.

Added database credentials (user name: 'django', password: 'blank') and
security check for db password. The security check will raise an error
if the database password is 'blank' in production.
This commit is contained in:
Bernd Meyer 2014-10-03 13:41:19 -07:00
parent 07435921a6
commit be5d237569
2 changed files with 14 additions and 11 deletions

View File

@ -1,13 +1,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import from __future__ import absolute_import
import os import os
from django.conf import settings
from django.core.checks import register, Error
from .local import Local # noqa from .local import Local # noqa
from .production import Production # noqa from .production import Production # noqa
try:
from django.conf import settings
from django.core.checks import register, Error
@register(settings) @register(settings)
def dj_database_url_check(app_configs=None, **kwargs): def dj_database_url_check(app_configs=None, **kwargs):
errors = [] errors = []
@ -16,3 +17,5 @@ def dj_database_url_check(app_configs=None, **kwargs):
if password == 'blank' and config == 'production': if password == 'blank' and config == 'production':
errors.append(Error('Change the database password for production.')) errors.append(Error('Change the database password for production.'))
return errors return errors
except ImportError:
pass

View File

@ -112,7 +112,7 @@ class Common(Configuration):
# DATABASE CONFIGURATION # DATABASE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = values.DatabaseURLValue('postgres://localhost/django:blank{{cookiecutter.repo_name}}') DATABASES = values.DatabaseURLValue('postgres://localhost/django:blank@{{cookiecutter.repo_name}}')
# END DATABASE CONFIGURATION # END DATABASE CONFIGURATION
# CACHING # CACHING