mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-31 10:19:54 +03:00
post_get_project.py hook
This commit is contained in:
parent
912aa36505
commit
7f747b9264
|
@ -37,7 +37,7 @@ Features
|
|||
* Pre configured Celery_ (optional)
|
||||
* Integration with Maildump_ for local email testing (optional)
|
||||
* Integration with Sentry_ for error logging (optional)
|
||||
* Docker support using docker-compose_ for dev and prod
|
||||
* Docker support using docker-compose_ for dev (with debug) and prod
|
||||
|
||||
.. _Hitch: https://github.com/hitchtest/hitchtest
|
||||
.. _Bootstrap: https://github.com/twbs/bootstrap
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
"use_celery": "n",
|
||||
"use_maildump": "n",
|
||||
"use_sentry": "n",
|
||||
"docker": "y",
|
||||
"use_docker": "n",
|
||||
"windows": "n"
|
||||
}
|
||||
|
|
25
hooks/post_gen_project.py
Normal file
25
hooks/post_gen_project.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import shutil
|
||||
|
||||
project_directory = os.path.realpath(os.path.curdir)
|
||||
|
||||
docker = '{{cookiecutter.use_docker}}' == 'y'
|
||||
|
||||
docker_files = [
|
||||
'debug.yml',
|
||||
'dev.yml',
|
||||
'docker-compose.yml',
|
||||
'Dockerfile'
|
||||
]
|
||||
|
||||
docker_dirs = [
|
||||
'compose/',
|
||||
]
|
||||
|
||||
if not docker:
|
||||
for path in docker_files:
|
||||
os.remove(os.path.join(project_directory, path))
|
||||
|
||||
for path in docker_dirs:
|
||||
shutil.rmtree(os.path.join(project_directory, path))
|
|
@ -99,7 +99,7 @@ MANAGERS = ADMINS
|
|||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||
DATABASES = {
|
||||
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
||||
{% if cookiecutter.docker == 'y' %}
|
||||
{% if cookiecutter.use_docker == 'y' %}
|
||||
'default': 'postgres://postgres@postgres/postgres'),
|
||||
{% else %}
|
||||
'default': env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.repo_name}}"),
|
||||
|
|
Loading…
Reference in New Issue
Block a user