From ce916f12e19f452eb342f227bf7c820a2ba25d21 Mon Sep 17 00:00:00 2001 From: Bernd Meyer Date: Fri, 3 Oct 2014 07:08:38 -0700 Subject: [PATCH 1/3] Added pytz to requirements/base.txt Added the latest version of pytz (2014.7) to requirements/base.txt to avoid errors with DateTime fields. --- {{cookiecutter.repo_name}}/requirements/base.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index 8e579eea3..74abc00a4 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -32,5 +32,7 @@ django-autoslug==1.7.2 # Useful things django-avatar==2.0 +# Time zones support +pytz==2014.7 # Your custom requirements go here From 07435921a6e56362f010673b150dd097c48559f3 Mon Sep 17 00:00:00 2001 From: Bernd Meyer Date: Fri, 3 Oct 2014 08:04:09 -0700 Subject: [PATCH 2/3] 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. --- .../{{cookiecutter.repo_name}}/config/__init__.py | 13 +++++++++++++ .../{{cookiecutter.repo_name}}/config/common.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py index feb8c8e1f..2fa0127a8 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py @@ -1,5 +1,18 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import +import os +from django.conf import settings +from django.core.checks import register, Error from .local import Local # noqa from .production import Production # noqa + + +@register(settings) +def dj_database_url_check(app_configs=None, **kwargs): + errors = [] + password = settings.DATABASES['default'].get('PASSWORD') + config = os.environ['DJANGO_CONFIGURATION'].lower() + if password == 'blank' and config == 'production': + errors.append(Error('Change the database password for production.')) + return errors diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py index caa4d1995..46c3e2a87 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py @@ -112,7 +112,7 @@ class Common(Configuration): # DATABASE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases - DATABASES = values.DatabaseURLValue('postgres://localhost/{{cookiecutter.repo_name}}') + DATABASES = values.DatabaseURLValue('postgres://localhost/django:blank{{cookiecutter.repo_name}}') # END DATABASE CONFIGURATION # CACHING From be5d237569fdece879dee5dfb051ab7f50020ba0 Mon Sep 17 00:00:00 2001 From: Bernd Meyer Date: Fri, 3 Oct 2014 13:41:19 -0700 Subject: [PATCH 3/3] 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. --- .../config/__init__.py | 23 +++++++++++-------- .../config/common.py | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py index 2fa0127a8..5f3d8cd54 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/__init__.py @@ -1,18 +1,21 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import import os -from django.conf import settings -from django.core.checks import register, Error from .local import Local # noqa from .production import Production # noqa -@register(settings) -def dj_database_url_check(app_configs=None, **kwargs): - errors = [] - password = settings.DATABASES['default'].get('PASSWORD') - config = os.environ['DJANGO_CONFIGURATION'].lower() - if password == 'blank' and config == 'production': - errors.append(Error('Change the database password for production.')) - return errors +try: + from django.conf import settings + from django.core.checks import register, Error + @register(settings) + def dj_database_url_check(app_configs=None, **kwargs): + errors = [] + password = settings.DATABASES['default'].get('PASSWORD') + config = os.environ['DJANGO_CONFIGURATION'].lower() + if password == 'blank' and config == 'production': + errors.append(Error('Change the database password for production.')) + return errors +except ImportError: + pass diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py index 46c3e2a87..f11e14fc8 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/common.py @@ -112,7 +112,7 @@ class Common(Configuration): # DATABASE CONFIGURATION # 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 # CACHING