From b8c6cdeaa349d64f0d6b0b68cdb427ada8c9f7f3 Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 18:55:45 +0200 Subject: [PATCH 1/7] Minor fixes. Reformat code. Upgrade packages version. Add DRF, rest-auth, django-constance. --- cookiecutter.json | 5 +- hooks/post_gen_project.py | 5 +- .../ansible/vagrant.yml | 1 - .../ansible/vars/vagrant.yml | 16 +-- {{cookiecutter.repo_name}}/config/settings.py | 109 ++++++++++++------ {{cookiecutter.repo_name}}/config/urls.py | 16 +-- {{cookiecutter.repo_name}}/env.example | 1 + .../requirements/base.txt | 54 ++++++--- .../requirements/local.txt | 7 +- .../common/admin.py | 5 +- .../{{cookiecutter.repo_name}}/common/apps.py | 3 + .../common/models.py | 7 +- .../common/tests.py | 5 +- .../{{cookiecutter.repo_name}}/common/urls.py | 5 +- .../common/views.py | 5 +- .../{{cookiecutter.repo_name}}/seo/admin.py | 3 +- .../{{cookiecutter.repo_name}}/seo/apps.py | 3 + .../seo/context_processors.py | 4 +- .../{{cookiecutter.repo_name}}/seo/models.py | 20 ++-- .../{{cookiecutter.repo_name}}/seo/tests.py | 5 +- .../{{cookiecutter.repo_name}}/seo/views.py | 5 +- .../static/css/project.css | 36 +++--- .../taskapp/celery.py | 7 +- .../templates/404.html | 2 +- .../templates/500.html | 7 +- .../templates/base.html | 72 ++++++------ .../{{cookiecutter.repo_name}}/users/admin.py | 6 +- .../{{cookiecutter.repo_name}}/users/apps.py | 3 + .../users/migrations/0001_initial.py | 5 +- .../users/models.py | 3 +- .../{{cookiecutter.repo_name}}/users/tests.py | 4 + .../{{cookiecutter.repo_name}}/users/urls.py | 3 +- .../{{cookiecutter.repo_name}}/users/views.py | 3 +- 33 files changed, 253 insertions(+), 182 deletions(-) create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests.py diff --git a/cookiecutter.json b/cookiecutter.json index c5d5ea8..2c0d2db 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -2,16 +2,19 @@ "project_name": "project_name", "repo_name": "{{ cookiecutter.project_name|replace(' ', '_') }}", "python_version": ["2", "3.5", "3.6"], + "use_django_rest_framework": "n", "use_postgresql": "y", "use_postgis": "n", "use_mysql": "n", "use_celery": "n", "use_allauth": "n", + "use_rest_auth": "n", "use_redis": "n", "use_rabbitmq": "n", "use_supervisor": "n", "use_apache": "n", "use_nginx": "n", "use_robots": "n", - "use_seo": "n" + "use_seo": "n", + "use_constance": "n" } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 2124db6..5357ec8 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -15,6 +15,7 @@ import random import shutil +import time from cookiecutter.config import DEFAULT_CONFIG # Get the root project directory @@ -30,6 +31,7 @@ # 'on your system. Falling back to Mersenne Twister.') using_sysrandom = False + def get_random_string( length=50, allowed_chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'): @@ -52,7 +54,8 @@ def get_random_string( time.time(), settings.SECRET_KEY)).encode('utf-8') ).digest()) - return ''.join(random.choice(allowed_chars) for i in range(length)) + return ''.join(random.choice(allowed_chars) for _ in range(length)) + def set_secret_key(setting_file_location): # Open locals.py diff --git a/{{cookiecutter.repo_name}}/ansible/vagrant.yml b/{{cookiecutter.repo_name}}/ansible/vagrant.yml index 9e35c00..9b9ea08 100644 --- a/{{cookiecutter.repo_name}}/ansible/vagrant.yml +++ b/{{cookiecutter.repo_name}}/ansible/vagrant.yml @@ -16,4 +16,3 @@ - { role: redis, when: "redis == true" } - { role: supervisor, when: "supervisor == true" } - { role: app, when: "app == true" } - diff --git a/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml b/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml index 91431fa..8a5d628 100644 --- a/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml +++ b/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml @@ -6,7 +6,7 @@ application_name: {{cookiecutter.repo_name}} # Database settings. db_user: "vagrant" db_name: "{{ application_name }}" -db_password: "" +db_password: "vagrant" # Application settings. virtualenv_path: "/home/vagrant/venv" @@ -20,11 +20,11 @@ django_settings: "config.settings" python_version: {{ cookiecutter.python_version }} # Services -mysql: {% if cookiecutter.use_mysql == "y" -%}true{% else %}no{%- endif %} -apache: {% if cookiecutter.use_apache == "y" -%}true{% else %}no{%- endif %} -nginx: {% if cookiecutter.use_nginx == "y" -%}true{% else %}no{%- endif %} -postgresql: {% if cookiecutter.use_postgresql == "y" or cookiecutter.use_postgis == "y" -%}true{% else %}no{%- endif %} -rabbitmq: {% if cookiecutter.use_rabbitmq == "y" -%}true{% else %}no{%- endif %} -redis: {% if cookiecutter.use_redis == "y" -%}true{% else %}no{%- endif %} -supervisor: {% if cookiecutter.use_supervisor == "y" -%}true{% else %}no{%- endif %} +mysql: {%- if cookiecutter.use_mysql == "y" -%}true{%- else -%}no{%- endif -%} +apache: {%- if cookiecutter.use_apache == "y" -%}true{%- else -%}no{%- endif -%} +nginx: {%- if cookiecutter.use_nginx == "y" -%}true{%- else -%}no{%- endif -%} +postgresql: {%- if cookiecutter.use_postgresql == "y" or cookiecutter.use_postgis == "y" -%}true{%- else -%}no{%- endif -%} +rabbitmq: {%- if cookiecutter.use_rabbitmq == "y" -%}true{%- else -%}no{%- endif -%} +redis: {%- if cookiecutter.use_redis == "y" -%}true{%- else -%}no{%- endif -%} +supervisor: {%- if cookiecutter.use_supervisor == "y" -%}true{%- else -%}no{%- endif -%} app: true diff --git a/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/config/settings.py index 13a6924..9e9ed4c 100644 --- a/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/config/settings.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals import os @@ -11,6 +10,8 @@ ROOT_DIR = environ.Path(__file__) - 2 # (/a/myfile.py - 2 = /) APPS_DIR = ROOT_DIR.path('{{ cookiecutter.repo_name }}') +TEST_RUNNING = True if len(environ.sys.argv) > 1 and environ.sys.argv[1] == 'test' else False + env = environ.Env( DJANGO_DEBUG=(bool, False), DJANGO_SECRET_KEY=(str, 'CHANGEME!!!'), @@ -23,18 +24,19 @@ DJANGO_DEFAULT_FROM_EMAIL=(str, 'admin@example.com'), DJANGO_EMAIL_BACKEND=(str, 'django.core.mail.backends.smtp.EmailBackend'), DJANGO_SERVER_EMAIL=(str, 'root@localhost.com'), - {% if cookiecutter.use_celery == "y" %} - {% if cookiecutter.use_redis == "y" -%} + {%- if cookiecutter.use_celery == "y" -%} + {%- if cookiecutter.use_redis == "y" -%} DJANGO_CELERY_BROKER_URL=(str, 'redis://localhost:6379/0'), DJANGO_CELERY_BACKEND=(str, 'redis://localhost:6379/0'), - {% elif cookiecutter.use_rabbitmq == "y" -%} + {%- elif cookiecutter.use_rabbitmq == "y" -%} DJANGO_CELERY_BROKER_URL=(str, 'amqp://guest:guest@localhost:5672//'), - {% else -%} + {%- else -%} DJANGO_CELERY_BROKER_URL=(str, 'django://'), - {% endif -%} + {%- endif -%} DJANGO_CELERY_ALWAYS_EAGER=(bool, False), - {% endif %} + {%- endif -%} DJANGO_USE_DEBUG_TOOLBAR=(bool, False), + DJANGO_USE_DEBUG_PANEL=(bool, False), DJANGO_TEST_RUN=(bool, False), DJANGO_HEALTH_CHECK_BODY=(str, 'Success'), @@ -43,7 +45,7 @@ environ.Env.read_env() -DEBUG = env.bool("DJANGO_DEBUG") +DEBUG = env.bool('DJANGO_DEBUG') SECRET_KEY = env('DJANGO_SECRET_KEY') @@ -83,26 +85,39 @@ 'django_extensions', {%- if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" %} 'kombu.transport.django', - {%- endif %} - {% if cookiecutter.use_allauth == 'y' -%} + {%- endif -%} + {%- if cookiecutter.use_allauth == 'y' -%} 'allauth', 'allauth.account', 'allauth.socialaccount', - {%- endif %} - {%- if cookiecutter.use_robots == "y" %} + {%- endif -%} + {%- if cookiecutter.use_constance == 'y' -%} + 'constance', + 'constance.backends.database', + {%- endif -%} + {%- if cookiecutter.use_django_rest_framework == "y" -%} + 'rest_framework', + 'rest_framework.authtoken', + 'corsheaders', + {%- endif -%} + {%- if if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" -%} + 'rest_auth', + 'rest_auth.registration', + {%- endif -%} + {%- if cookiecutter.use_robots == "y" -%} 'robots', - {%- endif %} - {%- if cookiecutter.use_seo == 'y' %} + {%- endif -%} + {%- if cookiecutter.use_seo == 'y' -%} 'solo', - {%- endif %} + {%- endif -%} ) LOCAL_APPS = ( '{{ cookiecutter.repo_name }}.common.apps.CommonConfig', '{{ cookiecutter.repo_name }}.users.apps.UsersConfig', - {%- if cookiecutter.use_seo == 'y' %} + {%- if cookiecutter.use_seo == 'y' -%} '{{ cookiecutter.repo_name }}.seo.apps.MetadataConfig', - {%- endif %} + {%- endif -%} ) INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS @@ -110,7 +125,7 @@ AUTH_USER_MODEL = 'users.User' ADMIN_URL = r'^admin/' -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -157,9 +172,9 @@ 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.contrib.messages.context_processors.messages', - {%- if cookiecutter.use_seo == 'y' %} + {%- if cookiecutter.use_seo == 'y' -%} '{{ cookiecutter.repo_name }}.seo.context_processors.get_page_meta_data', - {%- endif %} + {%- endif -%} ], }, }, @@ -183,34 +198,34 @@ ROOT_URLCONF = 'config.urls' WSGI_APPLICATION = 'config.wsgi.application' -{% if cookiecutter.use_celery == "y" %} +{%- if cookiecutter.use_celery == "y" -%} # celery settings BROKER_URL = env('DJANGO_CELERY_BROKER_URL') -{% if cookiecutter.use_redis == "y" -%} + {%- if cookiecutter.use_redis == "y" -%} CELERY_BACKEND = env('DJANGO_CELERY_BACKEND') -{% endif -%} + {%- endif -%} CELERY_ALWAYS_EAGER = env.bool('DJANGO_CELERY_ALWAYS_EAGER') -{%- endif %} +{%- endif -%} AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', - {% if cookiecutter.use_allauth == 'y' -%} + {%- if cookiecutter.use_allauth == 'y' -%} 'allauth.account.auth_backends.AuthenticationBackend', - {%- endif %} + {%- endif -%} ) -{% if cookiecutter.use_allauth == 'y' %} +{%- if cookiecutter.use_allauth == 'y' -%} ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' -{%- endif %} +{%- endif -%} -{%- if cookiecutter.use_robots == 'y' %} +{%- if cookiecutter.use_robots == 'y' -%} # Django-Robots ROBOTS_USE_HOST = False ROBOTS_USE_SITEMAP = False # cache is not updated if anything was changed # ROBOTS_CACHE_TIMEOUT = 60*60*24 # 24 hours -{%- endif %} +{%- endif -%} LOGGING = { 'version': 1, @@ -262,13 +277,16 @@ 'release': raven.fetch_git_sha(str(ROOT_DIR)), } -USE_DEBUG_TOOLBAR = env.bool('DJANGO_USE_DEBUG_TOOLBAR') +USE_DEBUG_TOOLBAR = env.bool('DJANGO_USE_DEBUG_TOOLBAR') if not TEST_RUNNING else False +USE_DEBUG_PANEL = env.bool('DJANGO_USE_DEBUG_PANEL') if not TEST_RUNNING else False if USE_DEBUG_TOOLBAR: - MIDDLEWARE_CLASSES += [ - 'debug_toolbar.middleware.DebugToolbarMiddleware', + middleware = 'debug_panel.middleware.DebugPanelMiddleware' if DJANGO_USE_DEBUG_PANEL else 'debug_toolbar.middleware.DebugToolbarMiddleware' # noqa + MIDDLEWARE += [ + middleware ] INSTALLED_APPS += ( 'debug_toolbar', + 'debug_panel', ) DEBUG_TOOLBAR_CONFIG = { 'DISABLE_PANELS': [ @@ -287,12 +305,12 @@ pass -{%- if cookiecutter.use_seo == 'y' %} +{%- if cookiecutter.use_seo == 'y' -%} SOLO_CACHE = 'default' SOLO_CACHE_TIMEOUT = 60*60*24 # 1 day SOLO_CACHE_PREFIX = 'solo' PAGE_META_DATA_CACHE_TIMEOUT = 60*60*12 # 12 hours -{%- endif %} +{%- endif -%} HEALTH_CHECK_BODY = env('DJANGO_HEALTH_CHECK_BODY') @@ -302,9 +320,28 @@ INSTALLED_APPS += ( 'silk', ) - MIDDLEWARE_CLASSES += [ + MIDDLEWARE += [ 'silk.middleware.SilkyMiddleware', ] SILKY_AUTHENTICATION = True # User must login SILKY_AUTHORISATION = True # User must have permissions SILKY_PERMISSIONS = lambda user: user.is_superuser + +{%- if cookiecutter.use_constance == 'y' -%} +# Django constance config +CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' +# CONSTANCE_CONFIG = {} +{%- endif -%} + +{%- if cookiecutter.use_django_rest_framework == 'y' -%} +# DRF config +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.TokenAuthentication', + ), +} +if not DEBUG: + REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = ( + 'rest_framework.renderers.JSONRenderer', + ) +{%- endif -%} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/config/urls.py b/{{cookiecutter.repo_name}}/config/urls.py index d476864..f53c1a5 100644 --- a/{{cookiecutter.repo_name}}/config/urls.py +++ b/{{cookiecutter.repo_name}}/config/urls.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import from django.conf import settings from django.conf.urls import include, url @@ -9,17 +9,17 @@ from django.views import defaults as default_views urlpatterns = [ - url(r'^$', TemplateView.as_view(template_name='base.html'), name="home"), + url(r'^$', TemplateView.as_view(template_name='base.html'), name='home'), {% raw %}# Django Admin, use {% url 'admin:index' %}{% endraw %} url(settings.ADMIN_URL, include(admin.site.urls)), - url(r'^users/', include("{{ cookiecutter.repo_name }}.users.urls", namespace="users")), - url(r'^common/', include("{{ cookiecutter.repo_name }}.common.urls", namespace="common")), - {%- if cookiecutter.use_allauth == 'y' %} + url(r'^users/', include('{{ cookiecutter.repo_name }}.users.urls', namespace='users')), + url(r'^common/', include('{{ cookiecutter.repo_name }}.common.urls', namespace='common')), + {%- if cookiecutter.use_allauth == 'y' -%} url(r'^accounts/', include('allauth.urls')), - {%- endif %} - {%- if cookiecutter.use_robots == 'y' %} + {%- endif -%} + {%- if cookiecutter.use_robots == 'y' -%} url(r'^robots\.txt', include('robots.urls')), - {%- endif %} + {%- endif -%} # Your stuff: custom urls includes go here ] diff --git a/{{cookiecutter.repo_name}}/env.example b/{{cookiecutter.repo_name}}/env.example index dbaa423..7cf148c 100644 --- a/{{cookiecutter.repo_name}}/env.example +++ b/{{cookiecutter.repo_name}}/env.example @@ -30,6 +30,7 @@ DJANGO_CELERY_ALWAYS_EAGER=off {%- endif %} DJANGO_USE_DEBUG_TOOLBAR=off +DJANGO_USE_DEBUG_PANEL=off DJANGO_TEST_RUN=off DJANGO_HEALTH_CHECK_BODY="Success" diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index 3402b57..e77a74a 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -1,24 +1,40 @@ -{%- if cookiecutter.use_celery == "y" -%} -celery==4.0.2 -{%- endif %} -Django==1.11.2 -{%- if cookiecutter.use_allauth == 'y' %} -django-allauth==0.32.0 -{%- endif %} +Django==1.11.7 +{%- if cookiecutter.use_allauth == 'y' -%} +django-allauth==0.34.0 +{%- endif -%} django-braces==1.11.0 -django-environ==0.4.3 -django-extensions==1.7.9 +{%- if cookiecutter.use_constance == 'y' -%} +django-constance[database]==2.0.0 +{%- endif -%} +{%- if cookiecutter.use_django_rest_framework == "y" -%} +django-cors-headers==2.1.0 +{%- endif -%} +django-environ==0.4.4 +django-extensions==1.9.7 django-model-utils==3.0.0 -Pillow==4.1.1 -psycopg2==2.7.1 -pytz==2017.2 -raven==6.1.0 -{%- if cookiecutter.use_redis == "y" %} -redis>=2.10.5 -django-redis-cache==1.7.1 -{%- endif %} -{%- if cookiecutter.use_robots == "y" %} +{%- if cookiecutter.use_robots == "y" -%} django-robots==3.0 -{%- endif %} +{%- endif -%} +{%- if cookiecutter.use_redis == "y" -%} +django-redis-cache==1.7.1 +{%- endif -%} django-solo==1.1.2 django-silk==1.0.0 + +{%- if cookiecutter.use_django_rest_framework == "y" -%} +djangorestframework==3.7.3 +{%- endif -%} +{%- if cookiecutter.use_rest_auth == "y" -%} +django-rest-auth==0.9.2 +{%- endif -%} + +Pillow==4.3.0 +psycopg2==2.7.3.2 +pytz==2017.3 +raven==6.3.0 +{%- if cookiecutter.use_redis == "y" -%} +redis>=2.10.5 +{%- endif -%} +{%- if cookiecutter.use_celery == "y" -%} +celery==4.1.0 +{%- endif -%} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/requirements/local.txt b/{{cookiecutter.repo_name}}/requirements/local.txt index 164fb33..9116a3d 100644 --- a/{{cookiecutter.repo_name}}/requirements/local.txt +++ b/{{cookiecutter.repo_name}}/requirements/local.txt @@ -1,7 +1,8 @@ -r base.txt -django-debug-toolbar==1.6 -ipdb==0.10.2 +django-debug-toolbar==1.9.1 +django-debug-panel==0.8.3 +ipdb==0.10.3 factory-boy==2.8.1 -coverage==4.3.4 +coverage==4.4.2 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/admin.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/admin.py index 8c38f3f..8dd51ba 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/admin.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/admin.py @@ -1,3 +1,4 @@ -from django.contrib import admin +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import -# Register your models here. +from django.contrib import admin diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/apps.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/apps.py index 26e0597..3d660d6 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/apps.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/apps.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import + from django.apps import AppConfig diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/models.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/models.py index 71a8362..3a1c5a1 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/models.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/models.py @@ -1,3 +1,6 @@ -from django.db import models +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import -# Create your models here. +from django.db import models +from django.utils.encoding import python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/tests.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/tests.py index 7ce503c..d7e5876 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/tests.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/tests.py @@ -1,3 +1,4 @@ -from django.test import TestCase +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import -# Create your tests here. +from django.test import TestCase diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/urls.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/urls.py index 038c50e..3de4be1 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/urls.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/urls.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import from django.conf.urls import url from .views import HealthCheckView - urlpatterns = [ url(r'^checker/$', HealthCheckView.as_view()), -] \ No newline at end of file +] diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/views.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/views.py index 1bd12f0..52c51b7 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/views.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/common/views.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import -from django.views.generic import View from django.conf import settings from django.http.response import HttpResponse +from django.views.generic import View class HealthCheckView(View): - def get(self, request, *args, **kwargs): return HttpResponse(settings.HEALTH_CHECK_BODY, status=200) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/admin.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/admin.py index 9d8861b..66838e2 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/admin.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/admin.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import from django.contrib import admin from solo.admin import SingletonModelAdmin + from . import models admin.site.register(models.DefaultPageMetaData, SingletonModelAdmin) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/apps.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/apps.py index e4a7dc9..fc60103 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/apps.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/apps.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import + from django.apps import AppConfig diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/context_processors.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/context_processors.py index c813d65..9f147d5 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/context_processors.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/context_processors.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import + import warnings from django.utils.translation import ugettext as _ + from .models import DefaultPageMetaData, PageMetaData diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/models.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/models.py index f97ce52..c26c0b7 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/models.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/models.py @@ -1,19 +1,17 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import -from django.db import models -from django.utils.translation import ugettext_lazy as _ -from django.utils.encoding import python_2_unicode_compatible -from django.core.cache import cache from django.conf import settings -from django.db.models.signals import pre_delete +from django.core.cache import cache +from django.db import models +from django.db.models.signals import pre_delete from django.dispatch import receiver - +from django.utils.encoding import python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ from solo.models import SingletonModel class PageMetaDataMixin(models.Model): - meta_keywords = models.CharField( max_length=160, null=True, blank=True, help_text=_('Unique coma-separated keywords for this page/item')) @@ -34,7 +32,6 @@ def save(self, *args, **kwargs): @python_2_unicode_compatible class DefaultPageMetaData(SingletonModel, PageMetaDataMixin): - class Meta: verbose_name = _('Default Page Meta Data') @@ -44,7 +41,6 @@ def __str__(self): @python_2_unicode_compatible class PageMetaData(PageMetaDataMixin): - url = models.CharField( max_length=200, help_text=_('Relative url E.g /home/ or /projects/'), @@ -70,7 +66,7 @@ def get_metadata(cls, url=None): "%s matching query does not exist." % cls._meta.object_name ) - + cache_name = cls.get_cache_name(url) cache_obj = cache.get(cache_name) @@ -95,4 +91,4 @@ def save(self, *args, **kwargs): def delete_cache(sender, instance, **kwargs): if sender == PageMetaData: cache_name = PageMetaData.get_cache_name(instance.url) - cache.delete(cache_name) \ No newline at end of file + cache.delete(cache_name) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/tests.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/tests.py index 7ce503c..d7e5876 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/tests.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/tests.py @@ -1,3 +1,4 @@ -from django.test import TestCase +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import -# Create your tests here. +from django.test import TestCase diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/views.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/views.py index 91ea44a..c80d22a 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/views.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/seo/views.py @@ -1,3 +1,2 @@ -from django.shortcuts import render - -# Create your views here. +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static/css/project.css b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static/css/project.css index 08505ae..386de13 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static/css/project.css +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/static/css/project.css @@ -1,32 +1,32 @@ /* These styles are generated from project.scss. */ .alert-debug { - color: black; - background-color: white; - border-color: #d6e9c6; + color: black; + background-color: white; + border-color: #d6e9c6; } .alert-error { - color: #b94a48; - background-color: #f2dede; - border-color: #eed3d7; + color: #b94a48; + background-color: #f2dede; + border-color: #eed3d7; } /* This is a fix for the bootstrap4 alpha release */ @media (max-width: 47.9em) { - .navbar-nav .nav-item { - float: none; - width: 100%; - display: inline-block; - } + .navbar-nav .nav-item { + float: none; + width: 100%; + display: inline-block; + } - .navbar-nav .nav-item + .nav-item { - margin-left: 0; - } + .navbar-nav .nav-item + .nav-item { + margin-left: 0; + } - .nav.navbar-nav.pull-right { - float: none !important; - } + .nav.navbar-nav.pull-right { + float: none !important; + } } /* Display django-debug-toolbar. @@ -34,5 +34,5 @@ and https://github.com/pydanny/cookiecutter-django/issues/317 */ [hidden][style="display: block;"] { - display: block !important; + display: block !important; } \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/taskapp/celery.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/taskapp/celery.py index 5d4253a..f873db0 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/taskapp/celery.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/taskapp/celery.py @@ -1,15 +1,12 @@ # -*- coding: utf-8 -*- - -from __future__ import absolute_import +from __future__ import unicode_literals, absolute_import import os from celery import Celery - from django.conf import settings - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') app = Celery('{{cookiecutter.repo_name}}') app.config_from_object('django.conf:settings') diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/404.html b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/404.html index 0d7a787..be426d2 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/404.html +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/404.html @@ -1,4 +1,4 @@ -{% raw %}{% extends "base.html" %} +{% raw %}{% extends 'base.html' %} {% block title %}Page Not found{% endblock %} diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/500.html b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/500.html index 122e081..ada9878 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/500.html +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/500.html @@ -1,4 +1,4 @@ -{% raw %}{% extends "base.html" %} +{% raw %}{% extends 'base.html' %} {% block title %}Server Error{% endblock %} @@ -7,7 +7,10 @@

Ooops!!! 500

Looks like something went wrong!

-

We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing.

+

+ We track these errors automatically, but if the problem persists feel free to contact us. + In the meantime, try refreshing. +

{% endblock content %} {% endraw %} diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html index 1bd58db..a6f3313 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html @@ -1,44 +1,46 @@ {% raw %}{% load staticfiles i18n %} - - - {% block title %}{% endraw %}{{ cookiecutter.project_name }}{% raw %}{% endblock title %} - - + - {% endraw %} - {%- if cookiecutter.use_seo == 'y' %} - {% raw %} - {% block seo %} - {% if meta_description %}{% endif %} - {% if meta_keywords %}{% endif %} - {% endblock seo %} - {% endraw %} - {%- endif %} - {% raw %} - {% block css %} - - {% endblock %} - - -
- {% if messages %} - {% for message in messages %} -
{{ message }}
- {% endfor %} - {% endif %} - {% block content %} -

Use this document as a way to quick start any new project.

- {% endblock content %} -
+ {% endraw %} + {%- if cookiecutter.use_seo == 'y' -%} + {% raw %} + {% block seo %} + {% if meta_description %} + {% endif %} + {% if meta_keywords %} + {% endif %} + {% endblock seo %} + {% endraw %} + {%- endif -%} + {% raw %} + {% block css %} + + {% endblock %} + + +
+ {% if messages %} + {% for message in messages %} +
{{ message }}
+ {% endfor %} + {% endif %} + {% block content %} +

Use this document as a way to quick start any new project.

+ {% endblock content %} +
- {% block modal %}{% endblock modal %} +{% block modal %}{% endblock modal %} - {% block javascript %} - - {% endblock javascript %} +{% block javascript %} + +{% endblock javascript %} - + {% endraw %} diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/admin.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/admin.py index 1ea4485..9d370ae 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/admin.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/admin.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals, absolute_import from django import forms from django.contrib import admin @@ -16,7 +15,6 @@ class Meta(UserChangeForm.Meta): class MyUserCreationForm(UserCreationForm): - error_message = UserCreationForm.error_messages.update({ 'duplicate_username': 'This username has already been taken.' }) @@ -25,7 +23,7 @@ class Meta(UserCreationForm.Meta): model = User def clean_username(self): - username = self.cleaned_data["username"] + username = self.cleaned_data['username'] try: User.objects.get(username=username) except User.DoesNotExist: diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/apps.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/apps.py index 0d7adad..4726601 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/apps.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/apps.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import + from django.apps import AppConfig diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0001_initial.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0001_initial.py index 8a04053..1599f06 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0001_initial.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/migrations/0001_initial.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.10.1 on 2016-09-14 09:10 -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import import django.contrib.auth.models import django.contrib.auth.validators @@ -24,7 +23,7 @@ class Migration(migrations.Migration): ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), - ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.ASCIIUsernameValidator()], verbose_name='username')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), ('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')), ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/models.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/models.py index e2960b7..c3f0bbb 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/models.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/models.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- - from __future__ import unicode_literals, absolute_import from django.contrib.auth.models import AbstractUser from django.db import models from django.utils.encoding import python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ @python_2_unicode_compatible class User(AbstractUser): - def __str__(self): return self.username diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests.py new file mode 100644 index 0000000..d7e5876 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/tests.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals, absolute_import + +from django.test import TestCase diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/urls.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/urls.py index 34ed724..1224ca4 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/urls.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/urls.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals, absolute_import from django.conf.urls import url diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/views.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/views.py index ee14b01..c80d22a 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/views.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/views.py @@ -1,3 +1,2 @@ # -*- coding: utf-8 -*- - -from __future__ import absolute_import, unicode_literals +from __future__ import unicode_literals, absolute_import From 5264fe233433a1924d8b469887dcbd9b21c16161 Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 19:06:42 +0200 Subject: [PATCH 2/7] Fix typo. --- {{cookiecutter.repo_name}}/config/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/config/settings.py index 9e9ed4c..863c04c 100644 --- a/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/config/settings.py @@ -83,7 +83,7 @@ THIRD_PARTY_APPS = ( 'django_extensions', - {%- if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" %} + {%- if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" -%} 'kombu.transport.django', {%- endif -%} {%- if cookiecutter.use_allauth == 'y' -%} From e2590b18795c2955b0ec41db82f7f59688f651f6 Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 19:11:01 +0200 Subject: [PATCH 3/7] Fix typo. --- {{cookiecutter.repo_name}}/config/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/config/settings.py index 863c04c..d0ee6b7 100644 --- a/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/config/settings.py @@ -100,7 +100,7 @@ 'rest_framework.authtoken', 'corsheaders', {%- endif -%} - {%- if if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" -%} + {%- if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" -%} 'rest_auth', 'rest_auth.registration', {%- endif -%} From 685e69a8a16ac7c4bbedc51d7c2f16e064a9d071 Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 19:16:59 +0200 Subject: [PATCH 4/7] Change templatetags format. --- {{cookiecutter.repo_name}}/README.md | 4 +- .../ansible/vars/vagrant.yml | 14 ++-- {{cookiecutter.repo_name}}/config/settings.py | 80 +++++++++---------- {{cookiecutter.repo_name}}/config/urls.py | 8 +- {{cookiecutter.repo_name}}/env.example | 18 ++--- .../requirements/base.txt | 36 ++++----- .../templates/base.html | 4 +- 7 files changed, 82 insertions(+), 82 deletions(-) diff --git a/{{cookiecutter.repo_name}}/README.md b/{{cookiecutter.repo_name}}/README.md index 37bc48d..93eb64d 100644 --- a/{{cookiecutter.repo_name}}/README.md +++ b/{{cookiecutter.repo_name}}/README.md @@ -1,3 +1,3 @@ -{%- if cookiecutter.use_robots == "y" %} +{% if cookiecutter.use_robots == "y" %} * ``./manage.py loaddata fixtures/robots_rules.json`` - default robots rules -{%- endif %} +{% endif %} diff --git a/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml b/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml index 8a5d628..016fa77 100644 --- a/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml +++ b/{{cookiecutter.repo_name}}/ansible/vars/vagrant.yml @@ -20,11 +20,11 @@ django_settings: "config.settings" python_version: {{ cookiecutter.python_version }} # Services -mysql: {%- if cookiecutter.use_mysql == "y" -%}true{%- else -%}no{%- endif -%} -apache: {%- if cookiecutter.use_apache == "y" -%}true{%- else -%}no{%- endif -%} -nginx: {%- if cookiecutter.use_nginx == "y" -%}true{%- else -%}no{%- endif -%} -postgresql: {%- if cookiecutter.use_postgresql == "y" or cookiecutter.use_postgis == "y" -%}true{%- else -%}no{%- endif -%} -rabbitmq: {%- if cookiecutter.use_rabbitmq == "y" -%}true{%- else -%}no{%- endif -%} -redis: {%- if cookiecutter.use_redis == "y" -%}true{%- else -%}no{%- endif -%} -supervisor: {%- if cookiecutter.use_supervisor == "y" -%}true{%- else -%}no{%- endif -%} +mysql: {% if cookiecutter.use_mysql == "y" %}true{% else %}no{% endif %} +apache: {% if cookiecutter.use_apache == "y" %}true{% else %}no{% endif %} +nginx: {% if cookiecutter.use_nginx == "y" %}true{% else %}no{% endif %} +postgresql: {% if cookiecutter.use_postgresql == "y" or cookiecutter.use_postgis == "y" %}true{% else %}no{% endif %} +rabbitmq: {% if cookiecutter.use_rabbitmq == "y" %}true{% else %}no{% endif %} +redis: {% if cookiecutter.use_redis == "y" %}true{% else %}no{% endif %} +supervisor: {% if cookiecutter.use_supervisor == "y" %}true{% else %}no{% endif %} app: true diff --git a/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/config/settings.py index d0ee6b7..c30bfbb 100644 --- a/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/config/settings.py @@ -24,17 +24,17 @@ DJANGO_DEFAULT_FROM_EMAIL=(str, 'admin@example.com'), DJANGO_EMAIL_BACKEND=(str, 'django.core.mail.backends.smtp.EmailBackend'), DJANGO_SERVER_EMAIL=(str, 'root@localhost.com'), - {%- if cookiecutter.use_celery == "y" -%} - {%- if cookiecutter.use_redis == "y" -%} + {% if cookiecutter.use_celery == "y" %} + {% if cookiecutter.use_redis == "y" %} DJANGO_CELERY_BROKER_URL=(str, 'redis://localhost:6379/0'), DJANGO_CELERY_BACKEND=(str, 'redis://localhost:6379/0'), - {%- elif cookiecutter.use_rabbitmq == "y" -%} + {% elif cookiecutter.use_rabbitmq == "y" %} DJANGO_CELERY_BROKER_URL=(str, 'amqp://guest:guest@localhost:5672//'), - {%- else -%} + {% else %} DJANGO_CELERY_BROKER_URL=(str, 'django://'), - {%- endif -%} + {% endif %} DJANGO_CELERY_ALWAYS_EAGER=(bool, False), - {%- endif -%} + {% endif %} DJANGO_USE_DEBUG_TOOLBAR=(bool, False), DJANGO_USE_DEBUG_PANEL=(bool, False), DJANGO_TEST_RUN=(bool, False), @@ -83,41 +83,41 @@ THIRD_PARTY_APPS = ( 'django_extensions', - {%- if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" -%} + {% if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" %} 'kombu.transport.django', - {%- endif -%} - {%- if cookiecutter.use_allauth == 'y' -%} + {% endif %} + {% if cookiecutter.use_allauth == 'y' %} 'allauth', 'allauth.account', 'allauth.socialaccount', - {%- endif -%} - {%- if cookiecutter.use_constance == 'y' -%} + {% endif %} + {% if cookiecutter.use_constance == 'y' %} 'constance', 'constance.backends.database', - {%- endif -%} - {%- if cookiecutter.use_django_rest_framework == "y" -%} + {% endif %} + {% if cookiecutter.use_django_rest_framework == "y" %} 'rest_framework', 'rest_framework.authtoken', 'corsheaders', - {%- endif -%} - {%- if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" -%} + {% endif %} + {% if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" %} 'rest_auth', 'rest_auth.registration', - {%- endif -%} - {%- if cookiecutter.use_robots == "y" -%} + {% endif %} + {% if cookiecutter.use_robots == "y" %} 'robots', - {%- endif -%} - {%- if cookiecutter.use_seo == 'y' -%} + {% endif %} + {% if cookiecutter.use_seo == 'y' %} 'solo', - {%- endif -%} + {% endif %} ) LOCAL_APPS = ( '{{ cookiecutter.repo_name }}.common.apps.CommonConfig', '{{ cookiecutter.repo_name }}.users.apps.UsersConfig', - {%- if cookiecutter.use_seo == 'y' -%} + {% if cookiecutter.use_seo == 'y' %} '{{ cookiecutter.repo_name }}.seo.apps.MetadataConfig', - {%- endif -%} + {% endif %} ) INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS @@ -172,9 +172,9 @@ 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.contrib.messages.context_processors.messages', - {%- if cookiecutter.use_seo == 'y' -%} + {% if cookiecutter.use_seo == 'y' %} '{{ cookiecutter.repo_name }}.seo.context_processors.get_page_meta_data', - {%- endif -%} + {% endif %} ], }, }, @@ -198,34 +198,34 @@ ROOT_URLCONF = 'config.urls' WSGI_APPLICATION = 'config.wsgi.application' -{%- if cookiecutter.use_celery == "y" -%} +{% if cookiecutter.use_celery == "y" %} # celery settings BROKER_URL = env('DJANGO_CELERY_BROKER_URL') - {%- if cookiecutter.use_redis == "y" -%} + {% if cookiecutter.use_redis == "y" %} CELERY_BACKEND = env('DJANGO_CELERY_BACKEND') - {%- endif -%} + {% endif %} CELERY_ALWAYS_EAGER = env.bool('DJANGO_CELERY_ALWAYS_EAGER') -{%- endif -%} +{% endif %} AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', - {%- if cookiecutter.use_allauth == 'y' -%} + {% if cookiecutter.use_allauth == 'y' %} 'allauth.account.auth_backends.AuthenticationBackend', - {%- endif -%} + {% endif %} ) -{%- if cookiecutter.use_allauth == 'y' -%} +{% if cookiecutter.use_allauth == 'y' %} ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' -{%- endif -%} +{% endif %} -{%- if cookiecutter.use_robots == 'y' -%} +{% if cookiecutter.use_robots == 'y' %} # Django-Robots ROBOTS_USE_HOST = False ROBOTS_USE_SITEMAP = False # cache is not updated if anything was changed # ROBOTS_CACHE_TIMEOUT = 60*60*24 # 24 hours -{%- endif -%} +{% endif %} LOGGING = { 'version': 1, @@ -305,12 +305,12 @@ pass -{%- if cookiecutter.use_seo == 'y' -%} +{% if cookiecutter.use_seo == 'y' %} SOLO_CACHE = 'default' SOLO_CACHE_TIMEOUT = 60*60*24 # 1 day SOLO_CACHE_PREFIX = 'solo' PAGE_META_DATA_CACHE_TIMEOUT = 60*60*12 # 12 hours -{%- endif -%} +{% endif %} HEALTH_CHECK_BODY = env('DJANGO_HEALTH_CHECK_BODY') @@ -327,13 +327,13 @@ SILKY_AUTHORISATION = True # User must have permissions SILKY_PERMISSIONS = lambda user: user.is_superuser -{%- if cookiecutter.use_constance == 'y' -%} +{% if cookiecutter.use_constance == 'y' %} # Django constance config CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' # CONSTANCE_CONFIG = {} -{%- endif -%} +{% endif %} -{%- if cookiecutter.use_django_rest_framework == 'y' -%} +{% if cookiecutter.use_django_rest_framework == 'y' %} # DRF config REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( @@ -344,4 +344,4 @@ REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = ( 'rest_framework.renderers.JSONRenderer', ) -{%- endif -%} \ No newline at end of file +{% endif %} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/config/urls.py b/{{cookiecutter.repo_name}}/config/urls.py index f53c1a5..d6179ec 100644 --- a/{{cookiecutter.repo_name}}/config/urls.py +++ b/{{cookiecutter.repo_name}}/config/urls.py @@ -14,12 +14,12 @@ url(settings.ADMIN_URL, include(admin.site.urls)), url(r'^users/', include('{{ cookiecutter.repo_name }}.users.urls', namespace='users')), url(r'^common/', include('{{ cookiecutter.repo_name }}.common.urls', namespace='common')), - {%- if cookiecutter.use_allauth == 'y' -%} + {% if cookiecutter.use_allauth == 'y' %} url(r'^accounts/', include('allauth.urls')), - {%- endif -%} - {%- if cookiecutter.use_robots == 'y' -%} + {% endif %} + {% if cookiecutter.use_robots == 'y' %} url(r'^robots\.txt', include('robots.urls')), - {%- endif -%} + {% endif %} # Your stuff: custom urls includes go here ] diff --git a/{{cookiecutter.repo_name}}/env.example b/{{cookiecutter.repo_name}}/env.example index 7cf148c..51a5c00 100644 --- a/{{cookiecutter.repo_name}}/env.example +++ b/{{cookiecutter.repo_name}}/env.example @@ -5,29 +5,29 @@ DJANGO_ADMINS=Some User:some.user@gmail.com, DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1 DJANGO_STATIC_ROOT=path/to/static/root DJANGO_MEDIA_ROOT=path/to/media/root -{% if cookiecutter.use_postgis == "y" -%} +{% if cookiecutter.use_postgis == "y" %} DJANGO_DATABASE_URL=postgis:///{{ cookiecutter.repo_name }} -{%- elif cookiecutter.use_postgresql == "y" -%} +{% elif cookiecutter.use_postgresql == "y" %} DJANGO_DATABASE_URL=postgres:///{{ cookiecutter.repo_name }} -{%- elif cookiecutter.use_mysql == "y" -%} +{% elif cookiecutter.use_mysql == "y" %} DJANGO_DATABASE_URL=mysql:///{{ cookiecutter.repo_name }} -{%- endif %} +{% endif %} DJANGO_EMAIL_URL="smtp://user@:password@localhost:25" DJANGO_DEFAULT_FROM_EMAIL=admin@example.com DJANGO_EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend DJANGO_SERVER_EMAIL=root@localhost.com {% if cookiecutter.use_celery == "y" %} -{% if cookiecutter.use_redis == "y" -%} +{% if cookiecutter.use_redis == "y" %} DJANGO_CELERY_BROKER_URL=redis://localhost:6379/1 DJANGO_CELERY_BACKEND=redis://localhost:6379/1 -{% elif cookiecutter.use_rabbitmq == "y" -%} +{% elif cookiecutter.use_rabbitmq == "y" %} DJANGO_CELERY_BROKER_URL=amqp://guest:guest@localhost:5672// -{% else -%} +{% else %} DJANGO_CELERY_BROKER_URL=django:// -{% endif -%} +{% endif %} DJANGO_CELERY_ALWAYS_EAGER=off -{%- endif %} +{% endif %} DJANGO_USE_DEBUG_TOOLBAR=off DJANGO_USE_DEBUG_PANEL=off diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index e77a74a..1ed8f1b 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -1,40 +1,40 @@ Django==1.11.7 -{%- if cookiecutter.use_allauth == 'y' -%} +{% if cookiecutter.use_allauth == 'y' %} django-allauth==0.34.0 -{%- endif -%} +{% endif %} django-braces==1.11.0 -{%- if cookiecutter.use_constance == 'y' -%} +{% if cookiecutter.use_constance == 'y' %} django-constance[database]==2.0.0 -{%- endif -%} -{%- if cookiecutter.use_django_rest_framework == "y" -%} +{% endif %} +{% if cookiecutter.use_django_rest_framework == "y" %} django-cors-headers==2.1.0 -{%- endif -%} +{% endif %} django-environ==0.4.4 django-extensions==1.9.7 django-model-utils==3.0.0 -{%- if cookiecutter.use_robots == "y" -%} +{% if cookiecutter.use_robots == "y" %} django-robots==3.0 -{%- endif -%} -{%- if cookiecutter.use_redis == "y" -%} +{% endif %} +{% if cookiecutter.use_redis == "y" %} django-redis-cache==1.7.1 -{%- endif -%} +{% endif %} django-solo==1.1.2 django-silk==1.0.0 -{%- if cookiecutter.use_django_rest_framework == "y" -%} +{% if cookiecutter.use_django_rest_framework == "y" %} djangorestframework==3.7.3 -{%- endif -%} -{%- if cookiecutter.use_rest_auth == "y" -%} +{% endif %} +{% if cookiecutter.use_rest_auth == "y" %} django-rest-auth==0.9.2 -{%- endif -%} +{% endif %} Pillow==4.3.0 psycopg2==2.7.3.2 pytz==2017.3 raven==6.3.0 -{%- if cookiecutter.use_redis == "y" -%} +{% if cookiecutter.use_redis == "y" %} redis>=2.10.5 -{%- endif -%} -{%- if cookiecutter.use_celery == "y" -%} +{% endif %} +{% if cookiecutter.use_celery == "y" %} celery==4.1.0 -{%- endif -%} \ No newline at end of file +{% endif %} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html index a6f3313..2e76abb 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/base.html @@ -8,7 +8,7 @@ {% endraw %} - {%- if cookiecutter.use_seo == 'y' -%} + {% if cookiecutter.use_seo == 'y' %} {% raw %} {% block seo %} {% if meta_description %} @@ -17,7 +17,7 @@ {% endif %} {% endblock seo %} {% endraw %} - {%- endif -%} + {% endif %} {% raw %} {% block css %} From f893c1c0122c77993dcfcadb4ed7147bb16ed3d4 Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 19:20:25 +0200 Subject: [PATCH 5/7] Update base requirements. --- .../requirements/base.txt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index 1ed8f1b..ed8e3c8 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -1,40 +1,40 @@ Django==1.11.7 -{% if cookiecutter.use_allauth == 'y' %} +{%- if cookiecutter.use_allauth == 'y' %} django-allauth==0.34.0 -{% endif %} +{%- endif %} django-braces==1.11.0 -{% if cookiecutter.use_constance == 'y' %} +{%- if cookiecutter.use_constance == 'y' %} django-constance[database]==2.0.0 -{% endif %} -{% if cookiecutter.use_django_rest_framework == "y" %} +{%- endif %} +{%- if cookiecutter.use_django_rest_framework == "y" %} django-cors-headers==2.1.0 -{% endif %} +{%- endif %} django-environ==0.4.4 django-extensions==1.9.7 django-model-utils==3.0.0 -{% if cookiecutter.use_robots == "y" %} +{%- if cookiecutter.use_robots == "y" %} django-robots==3.0 -{% endif %} -{% if cookiecutter.use_redis == "y" %} +{%- endif %} +{%- if cookiecutter.use_redis == "y" %} django-redis-cache==1.7.1 -{% endif %} +{%- endif %} django-solo==1.1.2 django-silk==1.0.0 -{% if cookiecutter.use_django_rest_framework == "y" %} +{%- if cookiecutter.use_django_rest_framework == "y" %} djangorestframework==3.7.3 -{% endif %} -{% if cookiecutter.use_rest_auth == "y" %} +{%- endif %} +{%- if cookiecutter.use_rest_auth == "y" %} django-rest-auth==0.9.2 -{% endif %} +{%- endif %} Pillow==4.3.0 psycopg2==2.7.3.2 pytz==2017.3 raven==6.3.0 -{% if cookiecutter.use_redis == "y" %} +{%- if cookiecutter.use_redis == "y" %} redis>=2.10.5 -{% endif %} -{% if cookiecutter.use_celery == "y" %} +{%- endif %} +{%- if cookiecutter.use_celery == "y" %} celery==4.1.0 {% endif %} \ No newline at end of file From 5084afb1c09b4f28dd243f2c9cf9bd3d04bfb7e4 Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 19:24:56 +0200 Subject: [PATCH 6/7] Update jinja templatetags format. --- {{cookiecutter.repo_name}}/config/settings.py | 70 +++++++++---------- {{cookiecutter.repo_name}}/config/urls.py | 8 +-- .../requirements/base.txt | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/config/settings.py index c30bfbb..fd0bfc0 100644 --- a/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/config/settings.py @@ -25,16 +25,16 @@ DJANGO_EMAIL_BACKEND=(str, 'django.core.mail.backends.smtp.EmailBackend'), DJANGO_SERVER_EMAIL=(str, 'root@localhost.com'), {% if cookiecutter.use_celery == "y" %} - {% if cookiecutter.use_redis == "y" %} + {%- if cookiecutter.use_redis == "y" %} DJANGO_CELERY_BROKER_URL=(str, 'redis://localhost:6379/0'), DJANGO_CELERY_BACKEND=(str, 'redis://localhost:6379/0'), - {% elif cookiecutter.use_rabbitmq == "y" %} + {%- elif cookiecutter.use_rabbitmq == "y" %} DJANGO_CELERY_BROKER_URL=(str, 'amqp://guest:guest@localhost:5672//'), - {% else %} + {%- else %} DJANGO_CELERY_BROKER_URL=(str, 'django://'), - {% endif %} + {%- endif %} DJANGO_CELERY_ALWAYS_EAGER=(bool, False), - {% endif %} + {%- endif %} DJANGO_USE_DEBUG_TOOLBAR=(bool, False), DJANGO_USE_DEBUG_PANEL=(bool, False), DJANGO_TEST_RUN=(bool, False), @@ -83,33 +83,33 @@ THIRD_PARTY_APPS = ( 'django_extensions', - {% if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" %} + {%- if cookiecutter.use_redis != "y" and cookiecutter.use_rabbitmq != "y" and cookiecutter.use_celery == "y" %} 'kombu.transport.django', - {% endif %} - {% if cookiecutter.use_allauth == 'y' %} + {%- endif %} + {%- if cookiecutter.use_allauth == 'y' %} 'allauth', 'allauth.account', 'allauth.socialaccount', - {% endif %} - {% if cookiecutter.use_constance == 'y' %} + {%- endif %} + {%- if cookiecutter.use_constance == 'y' %} 'constance', 'constance.backends.database', - {% endif %} - {% if cookiecutter.use_django_rest_framework == "y" %} + {%- endif %} + {%- if cookiecutter.use_django_rest_framework == "y" %} 'rest_framework', 'rest_framework.authtoken', 'corsheaders', - {% endif %} - {% if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" %} + {%- endif %} + {%- if cookiecutter.use_allauth == 'y' and cookiecutter.use_rest_auth == "y" %} 'rest_auth', 'rest_auth.registration', - {% endif %} - {% if cookiecutter.use_robots == "y" %} + {%- endif %} + {%- if cookiecutter.use_robots == "y" %} 'robots', - {% endif %} - {% if cookiecutter.use_seo == 'y' %} + {%- endif %} + {%- if cookiecutter.use_seo == 'y' %} 'solo', - {% endif %} + {%- endif %} ) LOCAL_APPS = ( @@ -174,7 +174,7 @@ 'django.contrib.messages.context_processors.messages', {% if cookiecutter.use_seo == 'y' %} '{{ cookiecutter.repo_name }}.seo.context_processors.get_page_meta_data', - {% endif %} + {%- endif %} ], }, }, @@ -201,31 +201,31 @@ {% if cookiecutter.use_celery == "y" %} # celery settings BROKER_URL = env('DJANGO_CELERY_BROKER_URL') - {% if cookiecutter.use_redis == "y" %} + {%- if cookiecutter.use_redis == "y" %} CELERY_BACKEND = env('DJANGO_CELERY_BACKEND') - {% endif %} + {%- endif %} CELERY_ALWAYS_EAGER = env.bool('DJANGO_CELERY_ALWAYS_EAGER') -{% endif %} +{%- endif %} AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', - {% if cookiecutter.use_allauth == 'y' %} + {%- if cookiecutter.use_allauth == 'y' %} 'allauth.account.auth_backends.AuthenticationBackend', - {% endif %} + {%- endif %} ) -{% if cookiecutter.use_allauth == 'y' %} +{%- if cookiecutter.use_allauth == 'y' %} ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' -{% endif %} +{%- endif %} -{% if cookiecutter.use_robots == 'y' %} +{%- if cookiecutter.use_robots == 'y' %} # Django-Robots ROBOTS_USE_HOST = False ROBOTS_USE_SITEMAP = False # cache is not updated if anything was changed # ROBOTS_CACHE_TIMEOUT = 60*60*24 # 24 hours -{% endif %} +{%- endif %} LOGGING = { 'version': 1, @@ -305,12 +305,12 @@ pass -{% if cookiecutter.use_seo == 'y' %} +{%- if cookiecutter.use_seo == 'y' %} SOLO_CACHE = 'default' SOLO_CACHE_TIMEOUT = 60*60*24 # 1 day SOLO_CACHE_PREFIX = 'solo' PAGE_META_DATA_CACHE_TIMEOUT = 60*60*12 # 12 hours -{% endif %} +{%- endif %} HEALTH_CHECK_BODY = env('DJANGO_HEALTH_CHECK_BODY') @@ -327,13 +327,13 @@ SILKY_AUTHORISATION = True # User must have permissions SILKY_PERMISSIONS = lambda user: user.is_superuser -{% if cookiecutter.use_constance == 'y' %} +{%- if cookiecutter.use_constance == 'y' %} # Django constance config CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend' # CONSTANCE_CONFIG = {} -{% endif %} +{%- endif %} -{% if cookiecutter.use_django_rest_framework == 'y' %} +{%- if cookiecutter.use_django_rest_framework == 'y' %} # DRF config REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( @@ -344,4 +344,4 @@ REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] = ( 'rest_framework.renderers.JSONRenderer', ) -{% endif %} \ No newline at end of file +{%- endif %} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/config/urls.py b/{{cookiecutter.repo_name}}/config/urls.py index d6179ec..0cb9b59 100644 --- a/{{cookiecutter.repo_name}}/config/urls.py +++ b/{{cookiecutter.repo_name}}/config/urls.py @@ -14,12 +14,12 @@ url(settings.ADMIN_URL, include(admin.site.urls)), url(r'^users/', include('{{ cookiecutter.repo_name }}.users.urls', namespace='users')), url(r'^common/', include('{{ cookiecutter.repo_name }}.common.urls', namespace='common')), - {% if cookiecutter.use_allauth == 'y' %} + {%- if cookiecutter.use_allauth == 'y' %} url(r'^accounts/', include('allauth.urls')), - {% endif %} - {% if cookiecutter.use_robots == 'y' %} + {%- endif %} + {%- if cookiecutter.use_robots == 'y' %} url(r'^robots\.txt', include('robots.urls')), - {% endif %} + {%- endif %} # Your stuff: custom urls includes go here ] diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index ed8e3c8..d5ff569 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -21,7 +21,7 @@ django-redis-cache==1.7.1 django-solo==1.1.2 django-silk==1.0.0 -{%- if cookiecutter.use_django_rest_framework == "y" %} +{% if cookiecutter.use_django_rest_framework == "y" %} djangorestframework==3.7.3 {%- endif %} {%- if cookiecutter.use_rest_auth == "y" %} From 3f0520ef49b206e45f4555271dcbc0e311575f3f Mon Sep 17 00:00:00 2001 From: Alexey Ternavskiy Date: Wed, 29 Nov 2017 19:35:50 +0200 Subject: [PATCH 7/7] Update jinja templatetags format. --- {{cookiecutter.repo_name}}/config/settings.py | 9 +++++---- {{cookiecutter.repo_name}}/requirements/base.txt | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/config/settings.py index fd0bfc0..fc62e77 100644 --- a/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/config/settings.py @@ -35,6 +35,7 @@ {%- endif %} DJANGO_CELERY_ALWAYS_EAGER=(bool, False), {%- endif %} + DJANGO_USE_DEBUG_TOOLBAR=(bool, False), DJANGO_USE_DEBUG_PANEL=(bool, False), DJANGO_TEST_RUN=(bool, False), @@ -115,9 +116,9 @@ LOCAL_APPS = ( '{{ cookiecutter.repo_name }}.common.apps.CommonConfig', '{{ cookiecutter.repo_name }}.users.apps.UsersConfig', - {% if cookiecutter.use_seo == 'y' %} + {%- if cookiecutter.use_seo == 'y' %} '{{ cookiecutter.repo_name }}.seo.apps.MetadataConfig', - {% endif %} + {%- endif %} ) INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS @@ -217,7 +218,7 @@ ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' -{%- endif %} +{% endif %} {%- if cookiecutter.use_robots == 'y' %} # Django-Robots @@ -280,7 +281,7 @@ USE_DEBUG_TOOLBAR = env.bool('DJANGO_USE_DEBUG_TOOLBAR') if not TEST_RUNNING else False USE_DEBUG_PANEL = env.bool('DJANGO_USE_DEBUG_PANEL') if not TEST_RUNNING else False if USE_DEBUG_TOOLBAR: - middleware = 'debug_panel.middleware.DebugPanelMiddleware' if DJANGO_USE_DEBUG_PANEL else 'debug_toolbar.middleware.DebugToolbarMiddleware' # noqa + middleware = 'debug_panel.middleware.DebugPanelMiddleware' if USE_DEBUG_PANEL else 'debug_toolbar.middleware.DebugToolbarMiddleware' # noqa MIDDLEWARE += [ middleware ] diff --git a/{{cookiecutter.repo_name}}/requirements/base.txt b/{{cookiecutter.repo_name}}/requirements/base.txt index d5ff569..ed8e3c8 100644 --- a/{{cookiecutter.repo_name}}/requirements/base.txt +++ b/{{cookiecutter.repo_name}}/requirements/base.txt @@ -21,7 +21,7 @@ django-redis-cache==1.7.1 django-solo==1.1.2 django-silk==1.0.0 -{% if cookiecutter.use_django_rest_framework == "y" %} +{%- if cookiecutter.use_django_rest_framework == "y" %} djangorestframework==3.7.3 {%- endif %} {%- if cookiecutter.use_rest_auth == "y" %}