mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-09 14:34:53 +03:00
Merge branch 'master' into bump-celery-to-4.1
This commit is contained in:
commit
3ce66c0b4d
33
.github/ISSUE_TEMPLATE.md
vendored
33
.github/ISSUE_TEMPLATE.md
vendored
|
@ -1,32 +1 @@
|
|||
**Note: for support questions, please use the `cookiecutter-django` tag on stackoverflow**. This repository's issues are reserved for feature requests and bug reports. If you need quick professional paid support for your project, contact support@cookiecutter.io.
|
||||
|
||||
* **I'm submitting a ... **
|
||||
- [ ] bug report
|
||||
- [ ] feature request
|
||||
- [ ] support request => Please do not submit support request here, see note at the top of this template.
|
||||
|
||||
|
||||
* **Do you want to request a *feature* or report a *bug*?**
|
||||
|
||||
|
||||
|
||||
* **What is the current behavior?**
|
||||
|
||||
|
||||
|
||||
* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem**
|
||||
|
||||
|
||||
* **What is the expected behavior?**
|
||||
|
||||
|
||||
|
||||
* **What is the motivation / use case for changing the behavior?**
|
||||
|
||||
|
||||
|
||||
* **Please tell us about your environment:**
|
||||
|
||||
|
||||
|
||||
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
|
||||
## [Make sure to follow one of the issue templates we've got](https://github.com/pydanny/cookiecutter-django/issues/new/choose), otherwise the issue might be closed immeditely
|
||||
|
|
23
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
name: Bug Report
|
||||
about: Report a bug
|
||||
---
|
||||
|
||||
## What happened?
|
||||
|
||||
|
||||
|
||||
|
||||
## What should've happened instead?
|
||||
|
||||
|
||||
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
[//]: # (Any or all of the following:)
|
||||
[//]: # (* Host system configuration: OS, Docker & friends' versions etc.)
|
||||
[//]: # (* Project generation options)
|
||||
[//]: # (* Logs)
|
||||
|
||||
|
24
.github/ISSUE_TEMPLATE/feature.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/feature.md
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
name: New Feature Proposal
|
||||
about: Propose a new feature
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
[//]: # (What's it you're proposing? How should it be implemented?)
|
||||
|
||||
|
||||
|
||||
|
||||
## Rationale
|
||||
|
||||
[//]: # (Why should this feature be implemented?)
|
||||
|
||||
|
||||
|
||||
|
||||
## Use case(s) / visualization(s)
|
||||
|
||||
[//]: # ("Better to see something once than to hear about it a thousand times.")
|
||||
|
||||
|
24
.github/ISSUE_TEMPLATE/improvement.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/improvement.md
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
name: Improvement Suggestion
|
||||
about: Let us know how we could improve
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
[//]: # (What's it you're proposing? How should it be implemented?)
|
||||
|
||||
|
||||
|
||||
|
||||
## Rationale
|
||||
|
||||
[//]: # (Why should this feature be implemented?)
|
||||
|
||||
|
||||
|
||||
|
||||
## Use case(s) / visualization(s)
|
||||
|
||||
[//]: # ("Better to see something once than to hear about it a thousand times.")
|
||||
|
||||
|
10
.github/ISSUE_TEMPLATE/paid-support.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/paid-support.md
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
name: Paid Support Request
|
||||
about: Ask Core Team members to help you out
|
||||
---
|
||||
|
||||
Provided your question goes beyound [regular support](https://github.com/pydanny/cookiecutter-django/issues/new?template=question.md), and/or the task at hand is of timely/high priority nature use the below information to reach out for contributors directly.
|
||||
|
||||
* Daniel Roy Greenfeld, Project Lead ([GitHub](https://github.com/pydanny), [Patreon](https://www.patreon.com/danielroygreenfeld)): expertise in Django and AWS ELB.
|
||||
|
||||
* Nikita Shupeyko, Core Developer ([GitHub](https://github.com/webyneter)): expertise in Django, Docker, and Heroku.
|
6
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
6
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
name: Question
|
||||
about: Please, ask your question on StackOverflow or Gitter
|
||||
---
|
||||
|
||||
First, make sure to examine [the docs](https://cookiecutter-django.readthedocs.io/en/latest/). If that doesn't help post a question on [StackOverflow](https://stackoverflow.com/questions/tagged/cookiecutter-django) tagged with `cookiecutter-django`. Finally, feel free to join [Gitter](https://gitter.im/pydanny/cookiecutter-django) and ask around.
|
28
.github/ISSUE_TEMPLATE/regression.md
vendored
Normal file
28
.github/ISSUE_TEMPLATE/regression.md
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
name: Regression Report
|
||||
about: Let us know if something that'd been working has broke
|
||||
---
|
||||
|
||||
## What happened before?
|
||||
|
||||
|
||||
|
||||
|
||||
## What happens now?
|
||||
|
||||
|
||||
|
||||
|
||||
## Last stable commit / Since when?
|
||||
|
||||
|
||||
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
[//]: # (Any or all of the following:)
|
||||
[//]: # (* Host system configuration: OS, Docker & friends' versions etc.)
|
||||
[//]: # (* Project generation options)
|
||||
[//]: # (* Logs)
|
||||
|
||||
|
27
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
27
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
[//]: # (Thank you for helping us out: your efforts mean great deal to the project and the community as a whole!)
|
||||
|
||||
[//]: # (Before you proceed:)
|
||||
|
||||
[//]: # (1. Make sure to add yourself to `CONTRIBUTORS.rst` through this PR provided you're contributing here for the first time)
|
||||
[//]: # (2. Don't forget to update the `docs/` presuming others would benefit from a concise description of whatever that you're proposing)
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
[//]: # (What's it you're proposing?)
|
||||
|
||||
|
||||
|
||||
|
||||
## Rationale
|
||||
|
||||
[//]: # (Why does the project need that?)
|
||||
|
||||
|
||||
|
||||
|
||||
## Use case(s) / visualization(s)
|
||||
|
||||
[//]: # ("Better to see something once than to hear about it a thousand times.")
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -226,3 +226,5 @@ pip-selfcheck.json
|
|||
# to 'run' anything within it since any particular cookiecutter
|
||||
# is declarative by nature.
|
||||
.idea/
|
||||
|
||||
.pytest_cache/
|
||||
|
|
19
.travis.yml
19
.travis.yml
|
@ -1,5 +1,3 @@
|
|||
# Config file for automatic testing at travis-ci.org
|
||||
|
||||
sudo: required
|
||||
|
||||
services:
|
||||
|
@ -10,27 +8,18 @@ language: python
|
|||
python: 3.6
|
||||
|
||||
env:
|
||||
- TOX_ENV=py36
|
||||
- TOX_ENV=py36
|
||||
|
||||
before_install:
|
||||
- sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" > /etc/apt/sources.list.d/docker.list'
|
||||
- sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
||||
- sudo apt-get update
|
||||
- sudo apt-key update
|
||||
- sudo apt-get --force-yes -qqy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install docker-engine=1.11.1-0~precise
|
||||
- sudo rm /usr/local/bin/docker-compose
|
||||
- curl -L https://github.com/docker/compose/releases/download/1.7.0/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
- docker-compose -v
|
||||
- docker -v
|
||||
|
||||
script:
|
||||
- tox -e $TOX_ENV
|
||||
- sh tests/test_docker.sh
|
||||
- tox -e $TOX_ENV
|
||||
- sh tests/test_docker.sh
|
||||
|
||||
install:
|
||||
- pip install tox
|
||||
- pip install tox
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
All enhancements and patches to Cookiecutter Django will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [2018-02-16]
|
||||
### Changed
|
||||
- Upgraded to Django 2.0 (@epicwhale)
|
||||
|
||||
## [2018-01-15]
|
||||
### Changed
|
||||
- Removed Elastic Beanstalk support (@pydanny)
|
||||
|
|
|
@ -16,8 +16,9 @@ Fábio C. Barrionuevo da Luz `@luzfcb`_ @luzfcb
|
|||
Saurabh Kumar `@theskumar`_ @_theskumar
|
||||
Jannis Gebauer `@jayfk`_
|
||||
Burhan Khalid `@burhan`_ @burhan
|
||||
Shupeyko Nikita `@webyneter`_ @webyneter
|
||||
Nikita Shupeyko `@webyneter`_ @webyneter
|
||||
Bruno Alla `@browniebroke`_ @_BrunoAlla
|
||||
Wan Liuyang `@sfdye`_ @sfdye
|
||||
=========================== ================ ===========
|
||||
|
||||
*Audrey is also the creator of Cookiecutter. Audrey and
|
||||
|
@ -30,6 +31,7 @@ Daniel are on the Cookiecutter core team.*
|
|||
.. _@jayfk: https://github.com/jayfk
|
||||
.. _@webyneter: https://github.com/webyneter
|
||||
.. _@browniebroke: https://github.com/browniebroke
|
||||
.. _@sfdye: https://github.com/sfdye
|
||||
|
||||
Other Contributors
|
||||
------------------
|
||||
|
@ -44,6 +46,7 @@ Listed in alphabetical order.
|
|||
Aaron Eikenberry `@aeikenberry`_
|
||||
Adam Bogdał `@bogdal`_
|
||||
Adam Dobrawy `@ad-m`_
|
||||
Adam Steele `@adammsteele`
|
||||
Agam Dua
|
||||
Alberto Sanchez `@alb3rto`_
|
||||
Alex Tsai `@caffodian`_
|
||||
|
@ -88,6 +91,7 @@ Listed in alphabetical order.
|
|||
Dong Huynh `@trungdong`_
|
||||
Emanuel Calso `@bloodpet`_ @bloodpet
|
||||
Eraldo Energy `@eraldo`_
|
||||
Eric Groom `@ericgroom`_
|
||||
Eyad Al Sibai `@eyadsibai`_
|
||||
Felipe Arruda `@arruda`_
|
||||
Garry Cairns `@garry-cairns`_
|
||||
|
@ -114,7 +118,9 @@ Listed in alphabetical order.
|
|||
Luis Nell `@originell`_
|
||||
Lukas Klein
|
||||
Lyla Fischer
|
||||
Malik Sulaimanov `@flyudvik`_ @flyudvik
|
||||
Martin Blech
|
||||
Martin Saizar `@msaizar`_
|
||||
Mathijs Hoogland `@MathijsHoogland`_
|
||||
Matt Braymer-Hayes `@mattayes`_ @mattayes
|
||||
Matt Linares
|
||||
|
@ -136,6 +142,7 @@ Listed in alphabetical order.
|
|||
Roman Afanaskin `@siauPatrick`_
|
||||
Roman Osipenko `@romanosipenko`_
|
||||
Russell Davies
|
||||
Sascha `@saschalalala` @saschalalala
|
||||
Sam Collins `@MightySCollins`_
|
||||
Shupeyko Nikita `@webyneter`_
|
||||
Sławek Ehlert `@slafs`_
|
||||
|
@ -151,7 +158,6 @@ Listed in alphabetical order.
|
|||
Travis McNeill `@Travistock`_ @tavistock_esq
|
||||
Vitaly Babiy
|
||||
Vivian Guillen `@viviangb`_
|
||||
Wan Liuyang `@sfdye`_ @sfdye
|
||||
Will Farley `@goldhand`_ @g01dhand
|
||||
William Archinal `@archinal`_
|
||||
Yaroslav Halchenko
|
||||
|
@ -159,6 +165,7 @@ Listed in alphabetical order.
|
|||
|
||||
.. _@a7p: https://github.com/a7p
|
||||
.. _@ad-m: https://github.com/ad-m
|
||||
.. _@adammsteele: https://github.com/adammsteele
|
||||
.. _@aeikenberry: https://github.com/aeikenberry
|
||||
.. _@alb3rto: https://github.com/alb3rto
|
||||
.. _@ameistad: https://github.com/ameistad
|
||||
|
@ -193,6 +200,7 @@ Listed in alphabetical order.
|
|||
.. _@eraldo: https://github.com/eraldo
|
||||
.. _@eriol: https://github.com/eriol
|
||||
.. _@eyadsibai: https://github.com/eyadsibai
|
||||
.. _@flyudvik: https://github.com/flyudvik
|
||||
.. _@garry-cairns: https://github.com/garry-cairns
|
||||
.. _@garrypolley: https://github.com/garrypolley
|
||||
.. _@goldhand: https://github.com/goldhand
|
||||
|
@ -211,6 +219,7 @@ Listed in alphabetical order.
|
|||
.. _@kevgathuku: https://github.com/kevgathuku
|
||||
.. _@knitatoms: https://github.com/knitatoms
|
||||
.. _@krzysztofzuraw: https://github.com/krzysztofzuraw
|
||||
.. _@msaizar: https://github.com/msaizar
|
||||
.. _@MathijsHoogland: https://github.com/MathijsHoogland
|
||||
.. _@mattayes: https://github.com/mattayes
|
||||
.. _@menzenski: https://github.com/menzenski
|
||||
|
@ -229,7 +238,6 @@ Listed in alphabetical order.
|
|||
.. _@romanosipenko: https://github.com/romanosipenko
|
||||
.. _@shireenrao: https://github.com/shireenrao
|
||||
.. _@show0k: https://github.com/show0k
|
||||
.. _@sfdye: https://github.com/sfdye
|
||||
.. _@shultz: https://github.com/shultz
|
||||
.. _@siauPatrick: https://github.com/siauPatrick
|
||||
.. _@slafs: https://github.com/slafs
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2013-2018, Daniel Greenfeld
|
||||
Copyright (c) 2013-2018, Daniel Roy Greenfeld
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
|
|
44
README.rst
44
README.rst
|
@ -16,6 +16,10 @@ Cookiecutter Django
|
|||
:target: https://www.codetriage.com/pydanny/cookiecutter-django
|
||||
:alt: Code Helpers Badge
|
||||
|
||||
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
||||
:target: https://github.com/ambv/black
|
||||
:alt: Code style: black
|
||||
|
||||
Powered by Cookiecutter_, Cookiecutter Django is a framework for jumpstarting
|
||||
production-ready Django projects quickly.
|
||||
|
||||
|
@ -23,9 +27,6 @@ production-ready Django projects quickly.
|
|||
* See Troubleshooting_ for common errors and obstacles
|
||||
* If you have problems with Cookiecutter Django, please open issues_ don't send
|
||||
emails to the maintainers.
|
||||
* Need quick professional paid support? Contact `support@cookiecutter.io`_.
|
||||
This includes configuring your servers, fixing bugs, reviewing your code and
|
||||
everything in between.
|
||||
|
||||
.. _cookiecutter: https://github.com/audreyr/cookiecutter
|
||||
|
||||
|
@ -33,15 +34,14 @@ production-ready Django projects quickly.
|
|||
|
||||
.. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373
|
||||
.. _issues: https://github.com/pydanny/cookiecutter-django/issues/new
|
||||
.. _support@cookiecutter.io: support@cookiecutter.io
|
||||
|
||||
Features
|
||||
---------
|
||||
|
||||
* For Django 1.11
|
||||
* For Django 2.0
|
||||
* Works with Python 3.6
|
||||
* Renders Django projects with 100% starting test coverage
|
||||
* Twitter Bootstrap_ v4.0.0 - beta 1 (`maintained Foundation fork`_ also available)
|
||||
* Twitter Bootstrap_ v4.0.0 (`maintained Foundation fork`_ also available)
|
||||
* 12-Factor_ based settings via django-environ_
|
||||
* Secure by default. We believe in SSL.
|
||||
* Optimized development and production settings
|
||||
|
@ -68,7 +68,6 @@ Optional Integrations
|
|||
* Configuration for Celery_
|
||||
* Integration with MailHog_ for local email testing
|
||||
* Integration with Sentry_ for error logging
|
||||
* Integration with Opbeat_ for performance monitoring
|
||||
|
||||
.. _Bootstrap: https://github.com/twbs/bootstrap
|
||||
.. _django-environ: https://github.com/joke2k/django-environ
|
||||
|
@ -83,7 +82,6 @@ Optional Integrations
|
|||
.. _MailHog: https://github.com/mailhog/MailHog
|
||||
.. _Sentry: https://sentry.io/welcome/
|
||||
.. _docker-compose: https://github.com/docker/compose
|
||||
.. _Opbeat: https://opbeat.com/
|
||||
.. _PythonAnywhere: https://www.pythonanywhere.com/
|
||||
.. _Caddy: https://caddyserver.com/
|
||||
.. _LetsEncrypt: https://letsencrypt.org/
|
||||
|
@ -111,7 +109,7 @@ Two Scoops of Django 1.11
|
|||
:name: Two Scoops of Django 1.11 Cover
|
||||
:align: center
|
||||
:alt: Two Scoops of Django
|
||||
:target: http://twoscoopspress.org/products/two-scoops-of-django-1-11
|
||||
:target: http://twoscoopspress.com/products/two-scoops-of-django-1-11
|
||||
|
||||
Two Scoops of Django is the best dessert-themed Django reference in the universe
|
||||
|
||||
|
@ -129,7 +127,7 @@ Pyup brings you automated security and dependency updates used by Google and oth
|
|||
Usage
|
||||
------
|
||||
|
||||
Let's pretend you want to create a Django project called "redditclone". Rather than using `startproject`
|
||||
Let's pretend you want to create a Django project called "redditclone". Rather than using ``startproject``
|
||||
and then editing the results to include your name, email, and various configuration issues that always get forgotten until the worst possible moment, get cookiecutter_ to do all the work.
|
||||
|
||||
First, get Cookiecutter. Trust me, it's awesome::
|
||||
|
@ -160,23 +158,23 @@ Answer the prompts with your own desired options_. For example::
|
|||
domain_name [example.com]: myreddit.com
|
||||
version [0.1.0]: 0.0.1
|
||||
timezone [UTC]: America/Los_Angeles
|
||||
use_whitenoise [y]: n
|
||||
use_whitenoise [n]: n
|
||||
use_celery [n]: y
|
||||
use_mailhog [n]: n
|
||||
use_sentry_for_error_reporting [y]: y
|
||||
use_opbeat [n]: y
|
||||
use_sentry [n]: y
|
||||
use_pycharm [n]: y
|
||||
windows [n]: n
|
||||
use_docker [y]: n
|
||||
use_docker [n]: n
|
||||
use_heroku [n]: y
|
||||
use_compressor [n]: y
|
||||
Select postgresql_version:
|
||||
1 - 10
|
||||
2 - 9.6
|
||||
3 - 9.5
|
||||
4 - 9.4
|
||||
5 - 9.3
|
||||
6 - 9.2
|
||||
1 - 10.3
|
||||
2 - 10.2
|
||||
3 - 10.1
|
||||
4 - 9.6
|
||||
5 - 9.5
|
||||
6 - 9.4
|
||||
7 - 9.3
|
||||
Choose from 1, 2, 3, 4 [1]: 1
|
||||
Select js_task_runner:
|
||||
1 - Gulp
|
||||
|
@ -191,6 +189,8 @@ Answer the prompts with your own desired options_. For example::
|
|||
4 - Apache Software License 2.0
|
||||
5 - Not open source
|
||||
Choose from 1, 2, 3, 4, 5 [1]: 1
|
||||
keep_local_envs_in_vcs [y]: y
|
||||
debug[n]: n
|
||||
|
||||
Enter the project and take a look around::
|
||||
|
||||
|
@ -279,6 +279,8 @@ experience better.
|
|||
Articles
|
||||
---------
|
||||
|
||||
* `cookiecutter-django with Nginx, Route 53 and ELB`_ - Feb. 12, 2018
|
||||
* `cookiecutter-django and Amazon RDS`_ - Feb. 7, 2018
|
||||
* `Deploying Cookiecutter-Django with Docker-Compose`_ - Oct. 19, 2017
|
||||
* `Using Cookiecutter to Jumpstart a Django Project on Windows with PyCharm`_ - May 19, 2017
|
||||
* `Exploring with Cookiecutter`_ - Dec. 3, 2016
|
||||
|
@ -290,6 +292,8 @@ Articles
|
|||
|
||||
Have a blog or online publication? Write about your cookiecutter-django tips and tricks, then send us a pull request with the link.
|
||||
|
||||
.. _`cookiecutter-django with Nginx, Route 53 and ELB`: https://msaizar.com/blog/cookiecutter-django-nginx-route-53-and-elb/
|
||||
.. _`cookiecutter-django and Amazon RDS`: https://msaizar.com/blog/cookiecutter-django-and-amazon-rds/
|
||||
.. _`Deploying Cookiecutter-Django with Docker-Compose`: http://adamantine.me/2017/10/19/deploying-cookiecutter-django-with-docker-compose/
|
||||
.. _`Exploring with Cookiecutter`: http://www.snowboardingcoder.com/django/2016/12/03/exploring-with-cookiecutter/
|
||||
.. _`Using Cookiecutter to Jumpstart a Django Project on Windows with PyCharm`: https://joshuahunter.com/posts/using-cookiecutter-to-jumpstart-a-django-project-on-windows-with-pycharm/
|
||||
|
|
|
@ -1,24 +1,45 @@
|
|||
{
|
||||
"project_name": "Project Name",
|
||||
"project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_') }}",
|
||||
"author_name": "Daniel Roy Greenfeld",
|
||||
"email": "you@example.com",
|
||||
"description": "A short description of the project.",
|
||||
"domain_name": "example.com",
|
||||
"version": "0.1.0",
|
||||
"timezone": "UTC",
|
||||
"use_whitenoise": "y",
|
||||
"use_celery": "n",
|
||||
"use_mailhog": "n",
|
||||
"use_sentry_for_error_reporting": "y",
|
||||
"use_opbeat": "n",
|
||||
"use_pycharm": "n",
|
||||
"windows": "n",
|
||||
"use_docker": "n",
|
||||
"use_heroku": "n",
|
||||
"use_compressor": "n",
|
||||
"postgresql_version": ["10", "9.6", "9.5", "9.4", "9.3", "9.2"],
|
||||
"js_task_runner": ["Gulp", "Grunt", "None"],
|
||||
"custom_bootstrap_compilation": "n",
|
||||
"open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"]
|
||||
"project_name": "My Awesome Project",
|
||||
"project_slug": "{{ cookiecutter.project_name.lower()|replace(' ', '_')|replace('-', '_') }}",
|
||||
"description": "Behold My Awesome Project!",
|
||||
"author_name": "Daniel Roy Greenfeld",
|
||||
"domain_name": "example.com",
|
||||
"email": "{{ cookiecutter.author_name.lower()|replace(' ', '-') }}@example.com",
|
||||
"version": "0.1.0",
|
||||
"open_source_license": [
|
||||
"MIT",
|
||||
"BSD",
|
||||
"GPLv3",
|
||||
"Apache Software License 2.0",
|
||||
"Not open source"
|
||||
],
|
||||
"timezone": "UTC",
|
||||
"windows": "n",
|
||||
"use_pycharm": "n",
|
||||
"use_docker": "n",
|
||||
"postgresql_version": [
|
||||
"10.4",
|
||||
"10.3",
|
||||
"10.2",
|
||||
"10.1",
|
||||
"9.6",
|
||||
"9.5",
|
||||
"9.4",
|
||||
"9.3"
|
||||
],
|
||||
"js_task_runner": [
|
||||
"None",
|
||||
"Gulp"
|
||||
],
|
||||
"custom_bootstrap_compilation": "n",
|
||||
"use_compressor": "n",
|
||||
"use_celery": "n",
|
||||
"use_mailhog": "n",
|
||||
"use_sentry": "n",
|
||||
"use_whitenoise": "n",
|
||||
"use_heroku": "n",
|
||||
"use_travisci": "n",
|
||||
"keep_local_envs_in_vcs": "y",
|
||||
|
||||
"debug": "n"
|
||||
}
|
||||
|
|
58
docs/conf.py
58
docs/conf.py
|
@ -29,29 +29,29 @@ now = datetime.now()
|
|||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = 'Cookiecutter Django'
|
||||
copyright = "2013-2016, Daniel Roy Greenfeld".format(now.year)
|
||||
project = "Cookiecutter Django"
|
||||
copyright = "2013-2018, Daniel Roy Greenfeld".format(now.year)
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '{}.{}.{}'.format(*now.isocalendar())
|
||||
version = "{}.{}.{}".format(*now.isocalendar())
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '{}.{}.{}'.format(*now.isocalendar())
|
||||
release = "{}.{}.{}".format(*now.isocalendar())
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -65,7 +65,7 @@ release = '{}.{}.{}'.format(*now.isocalendar())
|
|||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
# default_role = None
|
||||
|
@ -82,7 +82,7 @@ exclude_patterns = ['_build']
|
|||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
@ -92,7 +92,7 @@ pygments_style = 'sphinx'
|
|||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
|
@ -121,7 +121,7 @@ html_theme = 'default'
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
html_static_path = ["_static"]
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
|
@ -165,7 +165,7 @@ html_static_path = ['_static']
|
|||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'cookiecutter-djangodoc'
|
||||
htmlhelp_basename = "cookiecutter-djangodoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
@ -173,10 +173,8 @@ htmlhelp_basename = 'cookiecutter-djangodoc'
|
|||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
# 'preamble': '',
|
||||
}
|
||||
|
@ -184,10 +182,13 @@ latex_elements = {
|
|||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index',
|
||||
'cookiecutter-django.tex',
|
||||
'cookiecutter-django Documentation',
|
||||
'cookiecutter-django', 'manual'),
|
||||
(
|
||||
"index",
|
||||
"cookiecutter-django.tex",
|
||||
"cookiecutter-django Documentation",
|
||||
"cookiecutter-django",
|
||||
"manual",
|
||||
)
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -216,8 +217,13 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'Cookiecutter Django', 'Cookiecutter Django documentation',
|
||||
['Daniel Roy Greenfeld'], 1)
|
||||
(
|
||||
"index",
|
||||
"Cookiecutter Django",
|
||||
"Cookiecutter Django documentation",
|
||||
["Daniel Roy Greenfeld"],
|
||||
1,
|
||||
)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -230,9 +236,15 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Cookiecutter Django', 'Cookiecutter Django documentation',
|
||||
'Daniel Roy Greenfeld', 'Cookiecutter Django',
|
||||
'A Cookiecutter template for creating production-ready Django projects quickly.', 'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"Cookiecutter Django",
|
||||
"Cookiecutter Django documentation",
|
||||
"Daniel Roy Greenfeld",
|
||||
"Cookiecutter Django",
|
||||
"A Cookiecutter template for creating production-ready Django projects quickly.",
|
||||
"Miscellaneous",
|
||||
)
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
|
|
@ -14,26 +14,31 @@ Run these commands to deploy the project to Heroku:
|
|||
heroku pg:promote DATABASE_URL
|
||||
|
||||
heroku addons:create heroku-redis:hobby-dev
|
||||
heroku addons:create mailgun
|
||||
|
||||
heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 32)"
|
||||
heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)"
|
||||
heroku config:set DJANGO_SETTINGS_MODULE='config.settings.production'
|
||||
heroku config:set DJANGO_ALLOWED_HOSTS='.herokuapp.com'
|
||||
# If using mailgun:
|
||||
heroku addons:create mailgun:starter
|
||||
|
||||
heroku config:set DJANGO_AWS_ACCESS_KEY_ID=YOUR_AWS_ID_HERE
|
||||
heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY_HERE
|
||||
heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=YOUR_AWS_S3_BUCKET_NAME_HERE
|
||||
|
||||
heroku config:set DJANGO_MAILGUN_SERVER_NAME=YOUR_MALGUN_SERVER
|
||||
heroku config:set DJANGO_MAILGUN_API_KEY=YOUR_MAILGUN_API_KEY
|
||||
heroku config:set MAILGUN_SENDER_DOMAIN=YOUR_MAILGUN_SENDER_DOMAIN
|
||||
heroku addons:create sentry:f1
|
||||
|
||||
heroku config:set PYTHONHASHSEED=random
|
||||
heroku config:set DJANGO_ADMIN_URL=\^somelocation/
|
||||
heroku config:set WEB_CONCURRENCY=4
|
||||
heroku config:set DJANGO_DEBUG=False
|
||||
heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production
|
||||
heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)"
|
||||
# Generating a 32 character-long random string without any of the visually similiar characters "IOl01":
|
||||
heroku config:set DJANGO_ADMIN_URL="$(openssl rand -base64 4096 | tr -dc 'A-HJ-NP-Za-km-z2-9' | head -c 32)/"
|
||||
heroku config:set DJANGO_ALLOWED_HOSTS= # Set this to your Heroku app url, e.g. 'bionic-beaver-28392.herokuapp.com'
|
||||
|
||||
heroku config:set DJANGO_AWS_ACCESS_KEY_ID= # Assign with AWS_ACCESS_KEY_ID
|
||||
heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY= # Assign with AWS_SECRET_ACCESS_KEY
|
||||
heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME= # Assign with AWS_STORAGE_BUCKET_NAME
|
||||
|
||||
git push heroku master
|
||||
|
||||
heroku run python manage.py migrate
|
||||
heroku run python manage.py check --deploy
|
||||
heroku run python manage.py createsuperuser
|
||||
heroku run python manage.py collectstatic --no-input
|
||||
|
||||
heroku run python manage.py check --deploy
|
||||
|
||||
heroku open
|
||||
|
|
|
@ -63,13 +63,13 @@ Add these exports
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
export WEB_CONCURRENCY=4
|
||||
export DJANGO_SETTINGS_MODULE='config.settings.production'
|
||||
export DJANGO_SECRET_KEY='<secret key goes here>'
|
||||
export DJANGO_ALLOWED_HOSTS='<www.your-domain.com>'
|
||||
export DJANGO_ADMIN_URL='<not admin/>'
|
||||
export DJANGO_MAILGUN_API_KEY='<mailgun key>'
|
||||
export DJANGO_MAILGUN_SERVER_NAME='<mailgun server name>'
|
||||
export MAILGUN_SENDER_DOMAIN='<mailgun sender domain (e.g. mg.yourdomain.com)>'
|
||||
export MAILGUN_API_KEY='<mailgun key>'
|
||||
export MAILGUN_DOMAIN='<mailgun sender domain (e.g. mg.yourdomain.com)>'
|
||||
export DJANGO_AWS_ACCESS_KEY_ID=
|
||||
export DJANGO_AWS_SECRET_ACCESS_KEY=
|
||||
export DJANGO_AWS_STORAGE_BUCKET_NAME=
|
||||
|
@ -83,7 +83,7 @@ Database setup:
|
|||
|
||||
Go to the PythonAnywhere **Databases tab** and configure your database.
|
||||
|
||||
* For Postgres, setup your superuser password, then open a Postgres console and run a `CREATE DATABASE my-db-name`. You should probably also set up a specific role and permissions for your app, rather than using the superuser credentials. Make a note of the address and port of your postgres server.
|
||||
* For Postgres, setup your superuser password, then open a Postgres console and run a ``CREATE DATABASE my-db-name``. You should probably also set up a specific role and permissions for your app, rather than using the superuser credentials. Make a note of the address and port of your postgres server.
|
||||
|
||||
* For MySQL, set the password and create a database. More info here: https://help.pythonanywhere.com/pages/UsingMySQL
|
||||
|
||||
|
@ -138,9 +138,8 @@ Click through to the **WSGI configuration file** link (near the top) and edit th
|
|||
os.environ['DJANGO_SECRET_KEY'] = '<as above>'
|
||||
os.environ['DJANGO_ALLOWED_HOSTS'] = '<as above>'
|
||||
os.environ['DJANGO_ADMIN_URL'] = '<as above>'
|
||||
os.environ['DJANGO_MAILGUN_API_KEY'] = '<as above>'
|
||||
os.environ['DJANGO_MAILGUN_SERVER_NAME'] = '<as above>'
|
||||
os.environ['MAILGUN_SENDER_DOMAIN'] = '<as above>'
|
||||
os.environ['MAILGUN_API_KEY'] = '<as above>'
|
||||
os.environ['MAILGUN_DOMAIN'] = '<as above>'
|
||||
os.environ['DJANGO_AWS_ACCESS_KEY_ID'] = ''
|
||||
os.environ['DJANGO_AWS_SECRET_ACCESS_KEY'] = ''
|
||||
os.environ['DJANGO_AWS_STORAGE_BUCKET_NAME'] = ''
|
||||
|
|
|
@ -1,83 +1,82 @@
|
|||
Deployment with Docker
|
||||
=======================
|
||||
======================
|
||||
|
||||
.. index:: deployment, docker, docker-compose, compose
|
||||
|
||||
.. index:: Docker, deployment
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
* Docker (at least 1.10)
|
||||
* Docker Compose (at least 1.6)
|
||||
* Docker 1.10+.
|
||||
* Docker Compose 1.6+
|
||||
|
||||
Understand the Compose Setup
|
||||
--------------------------------
|
||||
|
||||
Before you start, check out the `production.yml` file in the root of this project. This is where each component
|
||||
of this application gets its configuration from. Notice how it provides configuration for these services:
|
||||
Understanding the Docker Compose Setup
|
||||
--------------------------------------
|
||||
|
||||
* `postgres` service that runs the database
|
||||
* `redis` for caching
|
||||
* `caddy` as webserver
|
||||
* `django` is the Django project run by gunicorn
|
||||
Before you begin, check out the ``production.yml`` file in the root of this project. Keep note of how it provides configuration for the following services:
|
||||
|
||||
If you chose the `use_celery` option, there are two more services:
|
||||
* ``django``: your application running behind ``Gunicorn``;
|
||||
* ``postgres``: PostgreSQL database with the application's relational data;
|
||||
* ``redis``: Redis instance for caching;
|
||||
* ``caddy``: Caddy web server with HTTPS on by default.
|
||||
|
||||
* `celeryworker` which runs the celery worker process
|
||||
* `celerybeat` which runs the celery beat process
|
||||
Provided you have opted for Celery (via setting ``use_celery`` to ``y``) there are two more services:
|
||||
|
||||
Populate .env With Your Environment Variables
|
||||
---------------------------------------------
|
||||
* ``celeryworker`` running a Celery worker process;
|
||||
* ``celerybeat`` running a Celery beat process.
|
||||
|
||||
Some of these services rely on environment variables set by you. There is an `env.example` file in the
|
||||
root directory of this project as a starting point. Add your own variables to the file and rename it to `.env`. This
|
||||
file won't be tracked by git by default so you'll have to make sure to use some other mechanism to copy your secret if
|
||||
you are relying solely on git.
|
||||
|
||||
It is **highly recommended** that before you build your production application, you set your POSTGRES_USER value here. This will create a non-default user for the postgres image. If you do not set this user before building the application, the default user 'postgres' will be created, and this user will not be able to create or restore backups.
|
||||
Configuring the Stack
|
||||
---------------------
|
||||
|
||||
To obtain logs and information about crashes in a production setup, make sure that you have access to an external Sentry instance (e.g. by creating an account with `sentry.io`_), and set the `DJANGO_SENTRY_DSN` variable. This should be enough to report crashes to Sentry.
|
||||
The majority of services above are configured through the use of environment variables. Just check out :ref:`envs` and you will know the drill.
|
||||
|
||||
To obtain logs and information about crashes in a production setup, make sure that you have access to an external Sentry instance (e.g. by creating an account with `sentry.io`_), and set the ``SENTRY_DSN`` variable.
|
||||
|
||||
You will probably also need to setup the Mail backend, for example by adding a `Mailgun`_ API key and a `Mailgun`_ sender domain, otherwise, the account creation view will crash and result in a 500 error when the backend attempts to send an email to the account owner.
|
||||
|
||||
.. _sentry.io: https://sentry.io/welcome
|
||||
.. _Mailgun: https://mailgun.com
|
||||
|
||||
HTTPS is on by default
|
||||
|
||||
Optional: Use AWS IAM Role for EC2 instance
|
||||
-------------------------------------------
|
||||
|
||||
If you are deploying to AWS, you can use the IAM role to substitute AWS credentials, after which it's safe to remove the ``AWS_ACCESS_KEY_ID`` AND ``AWS_SECRET_ACCESS_KEY`` from ``.envs/.production/.django``. To do it, create an `IAM role`_ and `attach`_ it to the existing EC2 instance or create a new EC2 instance with that role. The role should assume, at minimum, the ``AmazonS3FullAccess`` permission.
|
||||
|
||||
.. _IAM role: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html
|
||||
.. _attach: https://aws.amazon.com/blogs/security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/
|
||||
|
||||
|
||||
HTTPS is On by Default
|
||||
----------------------
|
||||
|
||||
SSL (Secure Sockets Layer) is a standard security technology for establishing an encrypted link between a server and a client, typically in this case, a web server (website) and a browser. Not having HTTPS means that malicious network users can sniff authentication credentials between your website and end users' browser.
|
||||
|
||||
It is always better to deploy a site behind HTTPS and will become crucial as the web services extend to the IoT (Internet of Things). For this reason, we have set up a number of security defaults to help make your website secure:
|
||||
|
||||
* In the `.env.example`, we have made it simpler for you to change the default `Django Admin` into a custom name through an environmental variable. This should make it harder to guess the access to the admin panel.
|
||||
|
||||
* If you are not using a subdomain of the domain name set in the project, then remember to put the your staging/production IP address in the :code:`DJANGO_ALLOWED_HOSTS` environment variable (see :ref:`settings`) before you deploy your website. Failure to do this will mean you will not have access to your website through the HTTP protocol.
|
||||
* If you are not using a subdomain of the domain name set in the project, then remember to put the your staging/production IP address in the ``DJANGO_ALLOWED_HOSTS`` environment variable (see :ref:`settings`) before you deploy your website. Failure to do this will mean you will not have access to your website through the HTTP protocol.
|
||||
|
||||
* Access to the Django admin is set up by default to require HTTPS in production or once *live*.
|
||||
|
||||
|
||||
HTTPS is configured by default
|
||||
------------------------------
|
||||
|
||||
The Caddy webserver used in the default configuration will get you a valid certificate from Lets Encrypt and update it automatically. All you need to do to enable this is to make sure that your DNS records are pointing to the server Caddy runs on.
|
||||
The Caddy web server used in the default configuration will get you a valid certificate from Lets Encrypt and update it automatically. All you need to do to enable this is to make sure that your DNS records are pointing to the server Caddy runs on.
|
||||
|
||||
You can read more about this here at `Automatic HTTPS`_ in the Caddy docs.
|
||||
|
||||
.. _Automatic HTTPS: https://caddyserver.com/docs/automatic-https
|
||||
|
||||
|
||||
Optional: Postgres Data Volume Modifications
|
||||
(Optional) Postgres Data Volume Modifications
|
||||
---------------------------------------------
|
||||
|
||||
Postgres is saving its database files to the `postgres_data` volume by default. Change that if you want something else and make sure to make backups since this is not done automatically.
|
||||
Postgres is saving its database files to the ``postgres_data`` volume by default. Change that if you want something else and make sure to make backups since this is not done automatically.
|
||||
|
||||
Run your app with docker-compose
|
||||
--------------------------------
|
||||
|
||||
To get started, pull your code from source control (don't forget the `.env` file) and change to your projects root
|
||||
directory.
|
||||
Building & Running Production Stack
|
||||
-----------------------------------
|
||||
|
||||
You'll need to build the stack first. To do that, run::
|
||||
You will need to build the stack first. To do that, run::
|
||||
|
||||
docker-compose -f production.yml build
|
||||
|
||||
|
@ -85,21 +84,23 @@ Once this is ready, you can run it with::
|
|||
|
||||
docker-compose -f production.yml up
|
||||
|
||||
To run the stack and detach the containers, run::
|
||||
|
||||
docker-compose -f production.yml up -d
|
||||
|
||||
To run a migration, open up a second terminal and run::
|
||||
|
||||
docker-compose -f production.yml run django python manage.py migrate
|
||||
docker-compose -f production.yml run --rm django python manage.py migrate
|
||||
|
||||
To create a superuser, run::
|
||||
|
||||
docker-compose -f production.yml run django python manage.py createsuperuser
|
||||
docker-compose -f production.yml run --rm django python manage.py createsuperuser
|
||||
|
||||
If you need a shell, run::
|
||||
|
||||
docker-compose -f production.yml run django python manage.py shell
|
||||
docker-compose -f production.yml run --rm django python manage.py shell
|
||||
|
||||
To get an output of all running containers.
|
||||
|
||||
To check your logs, run::
|
||||
To check the logs out, run::
|
||||
|
||||
docker-compose -f production.yml logs
|
||||
|
||||
|
@ -108,21 +109,21 @@ If you want to scale your application, run::
|
|||
docker-compose -f production.yml scale django=4
|
||||
docker-compose -f production.yml scale celeryworker=2
|
||||
|
||||
.. warning:: Don't run the scale command on postgres, celerybeat, or caddy.
|
||||
.. warning:: don't try to scale ``postgres``, ``celerybeat``, or ``caddy``.
|
||||
|
||||
If you have errors, you can always check your stack with `docker-compose`. Switch to your projects root directory and run::
|
||||
To see how your containers are doing run::
|
||||
|
||||
docker-compose -f production.yml ps
|
||||
|
||||
|
||||
Supervisor Example
|
||||
Example: Supervisor
|
||||
-------------------
|
||||
|
||||
Once you are ready with your initial setup, you want to make sure that your application is run by a process manager to
|
||||
survive reboots and auto restarts in case of an error. You can use the process manager you are most familiar with. All
|
||||
it needs to do is to run `docker-compose -f production.yml up` in your projects root directory.
|
||||
it needs to do is to run ``docker-compose -f production.yml up`` in your projects root directory.
|
||||
|
||||
If you are using `supervisor`, you can use this file as a starting point::
|
||||
If you are using ``supervisor``, you can use this file as a starting point::
|
||||
|
||||
[program:{{cookiecutter.project_slug}}]
|
||||
command=docker-compose -f production.yml up
|
||||
|
@ -132,11 +133,11 @@ If you are using `supervisor`, you can use this file as a starting point::
|
|||
autorestart=true
|
||||
priority=10
|
||||
|
||||
Place it in `/etc/supervisor/conf.d/{{cookiecutter.project_slug}}.conf` and run::
|
||||
Move it to ``/etc/supervisor/conf.d/{{cookiecutter.project_slug}}.conf`` and run::
|
||||
|
||||
supervisorctl reread
|
||||
supervisorctl start {{cookiecutter.project_slug}}
|
||||
|
||||
To get the status, run::
|
||||
For status check, run::
|
||||
|
||||
supervisorctl status
|
||||
|
|
|
@ -6,23 +6,19 @@ Getting Up and Running Locally With Docker
|
|||
The steps below will get you up and running with a local development environment.
|
||||
All of these commands assume you are in the root of your generated project.
|
||||
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
You'll need at least Docker 1.10.
|
||||
* Docker; if you don't have it yet, follow the `installation instructions`_;
|
||||
* Docker Compose; refer to the official documentation for the `installation guide`_.
|
||||
|
||||
If you don't already have it installed, follow the instructions for your OS:
|
||||
.. _`installation instructions`: https://docs.docker.com/install/#supported-platforms
|
||||
.. _`installation guide`: https://docs.docker.com/compose/install/
|
||||
|
||||
- On Mac OS X, you'll need `Docker for Mac`_
|
||||
- On Windows, you'll need `Docker for Windows`_
|
||||
- On Linux, you'll need `docker-engine`_
|
||||
|
||||
.. _`Docker for Mac`: https://docs.docker.com/engine/installation/mac/
|
||||
.. _`Docker for Windows`: https://docs.docker.com/engine/installation/windows/
|
||||
.. _`docker-engine`: https://docs.docker.com/engine/installation/
|
||||
|
||||
Attention Windows users
|
||||
-----------------------
|
||||
Attention, Windows Users
|
||||
------------------------
|
||||
|
||||
Currently PostgreSQL (``psycopg2`` python package) is not installed inside Docker containers for Windows users, while it is required by the generated Django project. To fix this, add ``psycopg2`` to the list of requirements inside ``requirements/base.txt``::
|
||||
|
||||
|
@ -31,23 +27,21 @@ Currently PostgreSQL (``psycopg2`` python package) is not installed inside Docke
|
|||
|
||||
Doing this will prevent the project from being installed in an Windows-only environment (thus without usage of Docker). If you want to use this project without Docker, make sure to remove ``psycopg2`` from the requirements again.
|
||||
|
||||
|
||||
Build the Stack
|
||||
---------------
|
||||
|
||||
This can take a while, especially the first time you run this particular command
|
||||
on your development system::
|
||||
This can take a while, especially the first time you run this particular command on your development system::
|
||||
|
||||
$ docker-compose -f local.yml build
|
||||
|
||||
If you want to build the production environment you use ``production.yml`` as -f argument (``docker-compose.yml`` or ``docker-compose.yaml`` are the defaults).
|
||||
Generally, if you want to emulate production environment use ``production.yml`` instead. And this is true for any other actions you might need to perform: whenever a switch is required, just do it!
|
||||
|
||||
Boot the System
|
||||
---------------
|
||||
|
||||
This brings up both Django and PostgreSQL.
|
||||
Run the Stack
|
||||
-------------
|
||||
|
||||
The first time it is run it might take a while to get started, but subsequent
|
||||
runs will occur quickly.
|
||||
This brings up both Django and PostgreSQL. The first time it is run it might take a while to get started, but subsequent runs will occur quickly.
|
||||
|
||||
Open a terminal at the project root and run the following for local development::
|
||||
|
||||
|
@ -61,98 +55,118 @@ And then run::
|
|||
|
||||
$ docker-compose up
|
||||
|
||||
Running management commands
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
To run in a detached (background) mode, just::
|
||||
|
||||
As with any shell command that we wish to run in our container, this is done
|
||||
using the ``docker-compose -f local.yml run`` command.
|
||||
$ docker-compose up -d
|
||||
|
||||
To migrate your app and to create a superuser, run::
|
||||
|
||||
$ docker-compose -f local.yml run django python manage.py migrate
|
||||
$ docker-compose -f local.yml run django python manage.py createsuperuser
|
||||
Execute Management Commands
|
||||
---------------------------
|
||||
|
||||
Here we specify the ``django`` container as the location to run our management commands.
|
||||
As with any shell command that we wish to run in our container, this is done using the ``docker-compose -f local.yml run --rm`` command: ::
|
||||
|
||||
Add your Docker development server IP
|
||||
-------------------------------------
|
||||
$ docker-compose -f local.yml run --rm django python manage.py migrate
|
||||
$ docker-compose -f local.yml run --rm django python manage.py createsuperuser
|
||||
|
||||
When ``DEBUG`` is set to `True`, the host is validated against ``['localhost', '127.0.0.1', '[::1]']``. This is adequate when running a ``virtualenv``. For Docker, in the ``config.settings.local``, add your host development server IP to ``INTERNAL_IPS`` or ``ALLOWED_HOSTS`` if the variable exists.
|
||||
Here, ``django`` is the target service we are executing the commands against.
|
||||
|
||||
Production Mode
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Instead of using `local.yml`, you would use `production.yml`.
|
||||
(Optionally) Designate your Docker Development Server IP
|
||||
--------------------------------------------------------
|
||||
|
||||
Other Useful Tips
|
||||
-----------------
|
||||
When ``DEBUG`` is set to ``True``, the host is validated against ``['localhost', '127.0.0.1', '[::1]']``. This is adequate when running a ``virtualenv``. For Docker, in the ``config.settings.local``, add your host development server IP to ``INTERNAL_IPS`` or ``ALLOWED_HOSTS`` if the variable exists.
|
||||
|
||||
Make a machine the active unit
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This tells our computer that all future commands are specifically for the dev1 machine.
|
||||
Using the ``eval`` command we can switch machines as needed.
|
||||
.. _envs:
|
||||
|
||||
::
|
||||
Configuring the Environment
|
||||
---------------------------
|
||||
|
||||
This is the excerpt from your project's ``local.yml``: ::
|
||||
|
||||
# ...
|
||||
|
||||
postgres:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./compose/production/postgres/Dockerfile
|
||||
volumes:
|
||||
- postgres_data_local:/var/lib/postgresql/data
|
||||
- postgres_backup_local:/backups
|
||||
env_file:
|
||||
- ./.envs/.local/.postgres
|
||||
|
||||
# ...
|
||||
|
||||
The most important thing for us here now is ``env_file`` section enlisting ``./.envs/.local/.postgres``. Generally, the stack's behavior is governed by a number of environment variables (`env(s)`, for short) residing in ``envs/``, for instance, this is what we generate for you: ::
|
||||
|
||||
.envs
|
||||
├── .local
|
||||
│ ├── .django
|
||||
│ └── .postgres
|
||||
└── .production
|
||||
├── .caddy
|
||||
├── .django
|
||||
└── .postgres
|
||||
|
||||
By convention, for any service ``sI`` in environment ``e`` (you know ``someenv`` is an environment when there is a ``someenv.yml`` file in the project root), given ``sI`` requires configuration, a ``.envs/.e/.sI`` `service configuration` file exists.
|
||||
|
||||
Consider the aforementioned ``.envs/.local/.postgres``: ::
|
||||
|
||||
# PostgreSQL
|
||||
# ------------------------------------------------------------------------------
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_DB=<your project slug>
|
||||
POSTGRES_USER=XgOWtQtJecsAbaIyslwGvFvPawftNaqO
|
||||
POSTGRES_PASSWORD=jSljDz4whHuwO3aJIgVBrqEml5Ycbghorep4uVJ4xjDYQu0LfuTZdctj7y0YcCLu
|
||||
|
||||
The three envs we are presented with here are ``POSTGRES_DB``, ``POSTGRES_USER``, and ``POSTGRES_PASSWORD`` (by the way, their values have also been generated for you). You might have figured out already where these definitions will end up; it's all the same with ``django`` and ``caddy`` service container envs.
|
||||
|
||||
One final touch: should you ever need to merge ``.envs/production/*`` in a single ``.env`` run the ``merge_production_dotenvs_in_dotenv.py``: ::
|
||||
|
||||
$ python merge_production_dotenvs_in_dotenv.py
|
||||
|
||||
The ``.env`` file will then be created, with all your production envs residing beside each other.
|
||||
|
||||
|
||||
Tips & Tricks
|
||||
-------------
|
||||
|
||||
Activate a Docker Machine
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This tells our computer that all future commands are specifically for the dev1 machine. Using the ``eval`` command we can switch machines as needed.::
|
||||
|
||||
$ eval "$(docker-machine env dev1)"
|
||||
|
||||
Detached Mode
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
If you want to run the stack in detached mode (in the background), use the ``-d`` argument:
|
||||
|
||||
::
|
||||
|
||||
$ docker-compose -f local.yml up -d
|
||||
|
||||
Debugging
|
||||
~~~~~~~~~~~~~
|
||||
~~~~~~~~~
|
||||
|
||||
ipdb
|
||||
"""""
|
||||
|
||||
If you are using the following within your code to debug:
|
||||
|
||||
::
|
||||
If you are using the following within your code to debug: ::
|
||||
|
||||
import ipdb; ipdb.set_trace()
|
||||
|
||||
Then you may need to run the following for it to work as desired:
|
||||
Then you may need to run the following for it to work as desired: ::
|
||||
|
||||
::
|
||||
|
||||
$ docker-compose -f local.yml run --service-ports django
|
||||
$ docker-compose -f local.yml run --rm --service-ports django
|
||||
|
||||
|
||||
django-debug-toolbar
|
||||
""""""""""""""""""""
|
||||
|
||||
In order for django-debug-toolbar to work with docker you need to add your docker-machine ip address to ``INTERNAL_IPS`` in ``local.py``
|
||||
In order for ``django-debug-toolbar`` to work designate your Docker Machine IP with ``INTERNAL_IPS`` in ``local.py``.
|
||||
|
||||
|
||||
.. May be a better place to put this, as it is not Docker specific.
|
||||
Mailhog
|
||||
~~~~~~~
|
||||
|
||||
You may need to add the following to your css in order for the django-debug-toolbar to be visible (this applies whether Docker is being used or not):
|
||||
When developing locally you can go with MailHog_ for email testing provided ``use_mailhog`` was set to ``y`` on setup. To proceed,
|
||||
|
||||
.. code-block:: css
|
||||
#. make sure ``mailhog`` container is up and running;
|
||||
|
||||
/* Override Bootstrap 4 styling on Django Debug Toolbar */
|
||||
#djDebug[hidden], #djDebug [hidden] {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
#djDebug [hidden][style='display: none;'] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
Using the Mailhog Docker Container
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In development you can (optionally) use MailHog_ for email testing. If you selected `use_docker`, MailHog is added as a Docker container. To use MailHog:
|
||||
|
||||
1. Make sure, that ``mailhog`` docker container is up and running
|
||||
2. Open your browser and go to ``http://127.0.0.1:8025``
|
||||
#. open up ``http://127.0.0.1:8025``.
|
||||
|
||||
.. _Mailhog: https://github.com/mailhog/MailHog/
|
||||
|
|
|
@ -3,74 +3,98 @@ Getting Up and Running Locally
|
|||
|
||||
.. index:: pip, virtualenv, PostgreSQL
|
||||
|
||||
The steps below will get you up and running with a local development environment. We assume you have the following installed:
|
||||
|
||||
* pip
|
||||
* virtualenv
|
||||
* PostgreSQL
|
||||
Setting Up Development Environment
|
||||
----------------------------------
|
||||
|
||||
First make sure to create and activate a virtualenv_.
|
||||
Make sure to have the following on your host:
|
||||
|
||||
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
|
||||
* virtualenv_;
|
||||
* pip;
|
||||
* PostgreSQL.
|
||||
|
||||
Then install the requirements for your local development::
|
||||
First things first.
|
||||
|
||||
#. `Create a virtualenv`_.
|
||||
|
||||
#. Activate the virtualenv you have just created.
|
||||
|
||||
#. Install development requirements: ::
|
||||
|
||||
$ pip install -r requirements/local.txt
|
||||
|
||||
Then, create a PostgreSQL database with the following command, where `[project_slug]` is what value you entered for your project's `project_slug`::
|
||||
#. Create a new PostgreSQL database (note: if this is the first time a database is created on your machine you might need to alter a localhost-related entry in your ``pg_hba.conf`` so as to utilize ``trust`` policy): ::
|
||||
|
||||
$ createdb [project_slug]
|
||||
$ createdb <what you've entered as the project_slug at setup stage>
|
||||
|
||||
You can now run the usual Django ``migrate`` and ``runserver`` commands::
|
||||
#. Apply migrations: ::
|
||||
|
||||
$ python manage.py migrate
|
||||
$ python manage.py runserver
|
||||
|
||||
At this point you can take a break from setup and start getting to know the files in the project.
|
||||
#. See the application being served through Django development server: ::
|
||||
|
||||
But if you want to go further with setup, read on.
|
||||
$ python manage.py runserver 0.0.0.0:8000
|
||||
|
||||
(Note: the following sections still need to be revised)
|
||||
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
|
||||
.. _`Create a virtualenv`: https://virtualenv.pypa.io/en/stable/userguide/
|
||||
|
||||
Setting Up Env Vars for Production
|
||||
-----------------------------------
|
||||
|
||||
`Cookiecutter Django` uses the excellent `django-environ`_ package, which includes a ``DATABASE_URL`` environment variable to simplify database configuration in your Django settings.
|
||||
Setup Email Backend
|
||||
-------------------
|
||||
|
||||
Rename env.example to .env to begin updating the file with your own environment variables. To add your database, define ``DATABASE_URL`` and add it to the .env file, as shown below:
|
||||
MailHog
|
||||
~~~~~~~
|
||||
|
||||
.. parsed-literal::
|
||||
.. note:: In order for the project to support MailHog_ it must have been bootstrapped with ``use_mailhog`` set to ``y``.
|
||||
|
||||
DATABASE_URL="postgres://*<pg_user_name>*:*<pg_user_password>*\ @127.0.0.1:\ *<pg_port>*/*<pg_database_name>*"
|
||||
MailHog is used to receive emails during development, it is written in Go and has no external dependencies.
|
||||
|
||||
.. _django-environ: http://django-environ.readthedocs.io
|
||||
For instance, one of the packages we depend upon, ``django-allauth`` sends verification emails to new users signing up as well as to the existing ones who have not yet verified themselves.
|
||||
|
||||
Setup your email backend
|
||||
-------------------------
|
||||
#. `Download the latest MailHog release`_ for your OS.
|
||||
|
||||
django-allauth sends an email to verify users (and superusers) after signup and login (if they are still not verified). To send email you need to `configure your email backend`_
|
||||
#. Rename the build to ``MailHog``.
|
||||
|
||||
.. _configure your email backend: https://docs.djangoproject.com/en/dev/topics/email/#smtp-backend
|
||||
#. Copy the file to the project root.
|
||||
|
||||
In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:
|
||||
#. Make it executable: ::
|
||||
|
||||
1. `Download the latest release`_ for your operating system
|
||||
2. Rename the executable to ``mailhog`` and copy it to the root of your project directory
|
||||
3. Make sure it is executable (e.g. ``chmod +x mailhog``)
|
||||
4. Execute mailhog from the root of your project in a new terminal window (e.g. ``./mailhog``)
|
||||
5. All emails generated from your django app can be seen on http://127.0.0.1:8025/
|
||||
$ chmod +x MailHog
|
||||
|
||||
.. _Mailhog: https://github.com/mailhog/MailHog/
|
||||
.. _Download the latest release: https://github.com/mailhog/MailHog/releases
|
||||
#. Spin up another terminal window and start it there: ::
|
||||
|
||||
Alternatively simply output emails to the console via: ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'``
|
||||
./MailHog
|
||||
|
||||
In production basic email configuration is setup to send emails with Mailgun_
|
||||
#. Check out `<http://127.0.0.1:8025/>`_ to see how it goes.
|
||||
|
||||
Now you have your own mail server running locally, ready to receive whatever you send it.
|
||||
|
||||
.. _MailHog: https://github.com/mailhog/MailHog/
|
||||
.. _`properly configured`: https://docs.djangoproject.com/en/dev/topics/email/#smtp-backend
|
||||
|
||||
|
||||
Console
|
||||
~~~~~~~
|
||||
|
||||
.. note:: If you have generated your project with ``use_mailhog`` set to ``n`` this will be a default setup.
|
||||
|
||||
Alternatively, deliver emails over console via ``EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'``.
|
||||
|
||||
In production, we have Mailgun_ configured to have your back!
|
||||
|
||||
.. _Mailgun: https://www.mailgun.com/
|
||||
|
||||
**Live reloading and Sass CSS compilation**
|
||||
|
||||
If you’d like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of `prep work`_.
|
||||
Sass Compilation & Live Reloading
|
||||
---------------------------------
|
||||
|
||||
.. _prep work: https://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html
|
||||
If you’d like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of preparation_.
|
||||
|
||||
.. _`Download the latest MailHog release`: https://github.com/mailhog/MailHog/releases
|
||||
.. _preparation: https://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html
|
||||
|
||||
|
||||
Summary
|
||||
-------
|
||||
|
||||
Congratulations, you have made it! Keep on reading to unleash full potential of Cookiecutter Django.
|
||||
|
|
|
@ -1,40 +1,87 @@
|
|||
============================
|
||||
Database Backups with Docker
|
||||
============================
|
||||
PostgreSQL Backups with Docker
|
||||
==============================
|
||||
|
||||
The database has to be running to create/restore a backup. These examples show local examples. If you want to use it on a remote server, remove ``-f local.yml`` from each example.
|
||||
.. note:: For brevity it is assumed that you will be running the below commands against local environment, however, this is by no means mandatory so feel free to switch to ``production.yml`` when needed.
|
||||
|
||||
Running Backups
|
||||
================
|
||||
|
||||
Run the app with `docker-compose -f local.yml up`.
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
#. the project was generated with ``use_docker`` set to ``y``;
|
||||
#. the stack is up and running: ``docker-compose -f local.yml up -d postgres``.
|
||||
|
||||
|
||||
Creating a Backup
|
||||
-----------------
|
||||
|
||||
To create a backup, run::
|
||||
|
||||
docker-compose -f local.yml run postgres backup
|
||||
$ docker-compose -f local.yml exec postgres backup
|
||||
|
||||
Assuming your project's database is named ``my_project`` here is what you will see: ::
|
||||
|
||||
Backing up the 'my_project' database...
|
||||
SUCCESS: 'my_project' database backup 'backup_2018_03_13T09_05_07.sql.gz' has been created and placed in '/backups'.
|
||||
|
||||
Keep in mind that ``/backups`` is the ``postgres`` container directory.
|
||||
|
||||
|
||||
To list backups, run::
|
||||
Viewing the Existing Backups
|
||||
----------------------------
|
||||
|
||||
docker-compose -f local.yml run postgres list-backups
|
||||
To list existing backups, ::
|
||||
|
||||
$ docker-compose -f local.yml exec postgres backups
|
||||
|
||||
These are the sample contents of ``/backups``: ::
|
||||
|
||||
These are the backups you have got:
|
||||
total 24K
|
||||
-rw-r--r-- 1 root root 5.2K Mar 13 09:05 backup_2018_03_13T09_05_07.sql.gz
|
||||
-rw-r--r-- 1 root root 5.2K Mar 12 21:13 backup_2018_03_12T21_13_03.sql.gz
|
||||
-rw-r--r-- 1 root root 5.2K Mar 12 21:12 backup_2018_03_12T21_12_58.sql.gz
|
||||
|
||||
|
||||
To restore a backup, run::
|
||||
Copying Backups Locally
|
||||
-----------------------
|
||||
|
||||
docker-compose -f local.yml run postgres restore filename.sql
|
||||
If you want to copy backups from your ``postgres`` container locally, ``docker cp`` command_ will help you on that.
|
||||
|
||||
Where <containerId> is the ID of the Postgres container. To get it, run::
|
||||
For example, given ``9c5c3f055843`` is the container ID copying all the backups over to a local directory is as simple as ::
|
||||
|
||||
docker ps
|
||||
$ docker cp 9c5c3f055843:/backups ./backups
|
||||
|
||||
To copy the files from the running Postgres container to the host system::
|
||||
With a single backup file copied to ``.`` that would be ::
|
||||
|
||||
docker cp <containerId>:/backups /host/path/target
|
||||
$ docker cp 9c5c3f055843:/backups/backup_2018_03_13T09_05_07.sql.gz .
|
||||
|
||||
Restoring From Backups
|
||||
======================
|
||||
.. _`command`: https://docs.docker.com/engine/reference/commandline/cp/
|
||||
|
||||
To restore the production database to a local PostgreSQL database::
|
||||
|
||||
createdb NAME_OF_DATABASE
|
||||
psql NAME_OF_DATABASE < NAME_OF_BACKUP_FILE
|
||||
Restoring from the Existing Backup
|
||||
----------------------------------
|
||||
|
||||
To restore from one of the backups you have already got (take the ``backup_2018_03_13T09_05_07.sql.gz`` for example), ::
|
||||
|
||||
$ docker-compose -f local.yml exec postgres restore backup_2018_03_13T09_05_07.sql.gz
|
||||
|
||||
You will see something like ::
|
||||
|
||||
Restoring the 'my_project' database from the '/backups/backup_2018_03_13T09_05_07.sql.gz' backup...
|
||||
INFO: Dropping the database...
|
||||
INFO: Creating a new database...
|
||||
INFO: Applying the backup to the new database...
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
SET
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SET
|
||||
# ...
|
||||
ALTER TABLE
|
||||
SUCCESS: The 'my_project' database has been restored from the '/backups/backup_2018_03_13T09_05_07.sql.gz' backup.
|
||||
|
|
12
docs/faq.rst
12
docs/faq.rst
|
@ -1,5 +1,5 @@
|
|||
FAQ
|
||||
====
|
||||
===
|
||||
|
||||
.. index:: FAQ, 12-Factor App
|
||||
|
||||
|
@ -17,11 +17,11 @@ Why aren't you using just one configuration file (12-Factor App)
|
|||
----------------------------------------------------------------------
|
||||
|
||||
TODO
|
||||
.. TODO
|
||||
|
||||
Why doesn't this follow the layout from Two Scoops of Django 1.8?
|
||||
----------------------------------------------------------------------
|
||||
Why doesn't this follow the layout from Two Scoops of Django?
|
||||
-------------------------------------------------------------
|
||||
|
||||
You may notice that some elements of this project do not exactly match what we describe in chapter 3 of `Two Scoops of Django`_. The reason for that is this project, amongst other things, serves as a test bed for trying out new ideas and concepts. Sometimes they work, sometimes they don't, but the end result is that it won't necessarily match precisely what is described in the book I co-authored.
|
||||
You may notice that some elements of this project do not exactly match what we describe in chapter 3 of `Two Scoops of Django 1.11`_. The reason for that is this project, amongst other things, serves as a test bed for trying out new ideas and concepts. Sometimes they work, sometimes they don't, but the end result is that it won't necessarily match precisely what is described in the book I co-authored.
|
||||
|
||||
|
||||
.. _`Two Scoops of Django`: http://twoscoopspress.com/products/two-scoops-of-django-1-8
|
||||
.. _Two Scoops of Django 1.11: https://www.twoscoopspress.com/collections/django/products/two-scoops-of-django-1-11
|
||||
|
|
|
@ -24,7 +24,6 @@ Contents:
|
|||
docker-postgres-backups
|
||||
faq
|
||||
troubleshooting
|
||||
my-favorite-cookie
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Live reloading and Sass CSS compilation
|
||||
=======================================
|
||||
Sass Compilation & Live Reloading
|
||||
=================================
|
||||
|
||||
If you'd like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of prep work.
|
||||
|
||||
|
@ -15,7 +15,7 @@ If you don't already have it, install `compass` (doesn't hurt if you run this co
|
|||
|
||||
Now you just need::
|
||||
|
||||
$ grunt serve
|
||||
$ npm run dev
|
||||
|
||||
The base app will now run as it would with the usual ``manage.py runserver`` but with live reloading and Sass compilation enabled.
|
||||
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
************************************************
|
||||
Creating your first app with Cookiecutter-Django
|
||||
************************************************
|
||||
|
||||
This tutorial will show you how to build a simple app using the `Cookiecutter Django <https://github.com/pydanny/cookiecutter-django>`_ templating system. We'll be building a cookie polling app to determine the most popular flavor of cookie.
|
||||
|
||||
Developers who have never used Django will learn the basics of creating a Django app; developers who are experienced with Django will learn how to set up a project within the Cookiecutter system. While many Django tutorials use the default SQLite database, Cookiecutter Django uses PostGres only, so we'll have you install and use that.
|
||||
|
||||
|
||||
Dependencies
|
||||
============
|
||||
This tutorial was written on Windows 10 using `git bash <https://git-for-windows.github.io/>`_; alternate instructions for Mac OS and Linux will be provided when needed. Any Linux-style shell should work for the following commands.
|
||||
|
||||
You should have your preferred versions of `Python <https://www.python.org/downloads/>`_
|
||||
and `Django <https://www.djangoproject.com/download/>`_ installed. Use the latest stable versions if you have no preference.
|
||||
|
||||
You should have `Virtualenv <https://virtualenv.pypa.io/en/stable/>`_ and `Cookiecutter <https://github.com/pydanny/cookiecutter-django/>`_ installed:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ pip install virtualenv
|
||||
$ pip install cookiecutter
|
||||
|
||||
You should also have `PostgreSQL <https://www.postgresql.org/download/>`_ installed on your machine--just download and run the installer for your OS. The install menu will prompt you for a password, which you'll use when creating the project's database.
|
||||
|
||||
|
||||
Instructions
|
||||
============
|
||||
|
||||
1. **Setup** -- how to set up a virtual environment
|
||||
2. **Cookiecutter** -- use Cookiecutter to initialize a project with your own customized information.
|
||||
3. **Building the App** -- creating the My Favorite Cookie application.
|
||||
|
||||
============
|
||||
1. Setup
|
||||
============
|
||||
|
||||
Virtual Environment
|
||||
"""""""""""""""""""
|
||||
|
||||
Create a virtual environment for your project. Cookiecutter will install a bunch of dependencies for you automatically; using a virtualenv will prevent this from interfering with your other work.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ virtualenv c:/.virtualenvs/cookie_polls
|
||||
|
||||
Replace ``c:/.virtualenvs`` with the path to your own ``.virtualenvs`` folder.
|
||||
|
||||
Activate the virtual environment by calling ``source`` on the ``activate`` shell script . On Windows you'll call this from the virtualenv's ``scripts`` folder:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ source /path/to/.virtualenvs/cookie_polls/scripts/activate
|
||||
|
||||
On other operating systems, it'll be found in the ``bin`` folder.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ source /path/to/.virtualenvs/cookie_polls/bin/activate
|
||||
|
||||
You'll know the virtual environment is active because its name will appear in parentheses before the command prompt. When you're done with this project, you can leave the virtual environment with the ``deactivate`` command.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
(cookie_polls)
|
||||
$ deactivate
|
||||
|
||||
|
||||
Now you're ready to create your project using Cookiecutter.
|
||||
|
||||
|
||||
===============
|
||||
2. Cookiecutter
|
||||
===============
|
||||
|
||||
Django developers may be familiar with the ``startproject`` command, which initializes the directory structure and required files for a bare-bones Django project. While this is fine when you're just learning Django for the first time, it's not great for a real production app. Cookiecutter takes care of a lot of standard tasks for you, including installing software dependencies, setting up testing files, and including and organizing common libraries like Bootstrap and AngularJS. It also generates a software license and a README.
|
||||
|
||||
Change directories into the folder where you want your project to live, and run ``cookiecutter`` followed by the URL of Cookiecutter's Github repo.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
$ cd /my/project/folder
|
||||
(cookie_polls)
|
||||
my/project/folder
|
||||
$ cookiecutter https://github.com/pydanny/cookiecutter-django
|
||||
|
||||
This will prompt you for a bunch of values specific to your project. Press "enter" without typing anything to use the default values, which are shown in [brackets] after the question. You can learn about all the different options `here, <http://cookiecutter-django.readthedocs.io/en/latest/project-generation-options.html>`_ but for now we'll use the defaults for everything but your name, your email, the project's name, and the project's description.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
project_name [project_name]: My Favorite Cookie
|
||||
project_slug [My_Favorite_Cookie]:
|
||||
author_name [Your Name]: Emily Cain
|
||||
email [Your email]: contact@emcain.net
|
||||
description [A short description of the project.]: Poll your friends to determine the most popular cookie.
|
||||
|
||||
Then hit "enter" to use the default values for everything else.
|
||||
|
||||
|
||||
|
|
@ -1,84 +1,32 @@
|
|||
Project Generation Options
|
||||
==========================
|
||||
|
||||
project_name [project_name]:
|
||||
Your human-readable project name, including any capitalization or spaces.
|
||||
project_name:
|
||||
Your project's human-readable name, capitals and spaces allowed.
|
||||
|
||||
project_slug [project_name]:
|
||||
The slug of your project, without dashes or spaces. Used to name your repo
|
||||
project_slug:
|
||||
Your project's slug without dashes or spaces. Used to name your repo
|
||||
and in other places where a Python-importable version of your project name
|
||||
is needed.
|
||||
|
||||
author_name [Your Name]:
|
||||
You! This goes into places like the LICENSE file.
|
||||
description:
|
||||
Describes your project and gets used in places like ``README.rst`` and such.
|
||||
|
||||
email [Your email]:
|
||||
Your email address.
|
||||
author_name:
|
||||
This is you! The value goes into places like ``LICENSE`` and such.
|
||||
|
||||
description [A short description of the project.]
|
||||
Used in the generated README.rst and other places.
|
||||
email:
|
||||
The email address you want to identify yourself in the project.
|
||||
|
||||
domain_name [example.com]
|
||||
Whatever domain name you plan to use for your project when it goes live.
|
||||
domain_name:
|
||||
The domain name you plan to use for your project once it goes live.
|
||||
Note that it can be safely changed later on whenever you need to.
|
||||
|
||||
version [0.1.0]
|
||||
The starting version number for your project.
|
||||
version:
|
||||
The version of the project at its inception.
|
||||
|
||||
timezone [UTC]
|
||||
Used in the base settings file for the `TIME_ZONE` value.
|
||||
|
||||
use_whitenoise [y]
|
||||
Whether to use WhiteNoise_ for static file serving.
|
||||
|
||||
use_celery [n]
|
||||
Whether to use Celery_. This gives you the ability to use distributed task
|
||||
queues in your project.
|
||||
|
||||
use_mailhog [n]
|
||||
Whether to use MailHog_. MailHog is a tool that simulates email receiving
|
||||
for development purposes. It runs a simple SMTP server which catches
|
||||
any message sent to it. Messages are displayed in a web interface which
|
||||
runs at ``http://localhost:8025/`` You need to download the MailHog
|
||||
executable for your operating system, see the 'Developing Locally' docs
|
||||
for instructions.
|
||||
|
||||
use_sentry_for_error_reporting [n]
|
||||
Whether to use Sentry_ to log errors from your project.
|
||||
|
||||
use_opbeat [n]
|
||||
Whether to use Opbeat_ for preformance monitoring and code optimization.
|
||||
|
||||
use_pycharm [n]
|
||||
Adds support for developing in PyCharm_ with a preconfigured .idea directory.
|
||||
|
||||
windows [n]
|
||||
Whether you'll be developing on Windows.
|
||||
|
||||
use_docker [y]
|
||||
Whether to use Docker_, separating the app and database into separate
|
||||
containers.
|
||||
|
||||
use_heroku [n]
|
||||
Add configuration to deploy the application to a Heroku_ instance.
|
||||
|
||||
use_compressor [n]
|
||||
Use `Django Compressor`_ to minify and combine rendered JavaScript and CSS
|
||||
into cachable static resources.
|
||||
|
||||
js_task_runner [1]
|
||||
Select a JavaScript task runner. The choices are:
|
||||
|
||||
1. Gulp_
|
||||
2. Grunt_
|
||||
3. None
|
||||
|
||||
custom_bootstrap_compilation [n]
|
||||
Scaffold out recompiling Bootstrap as as task, with Gulp_ or Grunt_.
|
||||
Useful for letting you change Bootstrap variables in real time.
|
||||
Consult project README for more details.
|
||||
|
||||
open_source_license [1]
|
||||
Select a software license for the project. The choices are:
|
||||
open_source_license:
|
||||
A software license for the project. The choices are:
|
||||
|
||||
1. MIT_
|
||||
2. BSD_
|
||||
|
@ -86,23 +34,96 @@ open_source_license [1]
|
|||
4. `Apache Software License 2.0`_
|
||||
5. Not open source
|
||||
|
||||
**NOTE:** *If you choose to use Docker, selecting a JavaScript task runner is
|
||||
not supported out of the box.*
|
||||
timezone:
|
||||
The value to be used for the ``TIME_ZONE`` setting of the project.
|
||||
|
||||
windows:
|
||||
Indicates whether the project should be configured for development on Windows.
|
||||
|
||||
use_pycharm:
|
||||
Indicates whether the project should be configured for development with PyCharm_.
|
||||
|
||||
use_docker:
|
||||
Indicates whether the project should be configured to use Docker_ and `Docker Compose`_.
|
||||
|
||||
postgresql_version:
|
||||
Select a PostgreSQL_ version to use. The choices are:
|
||||
|
||||
1. 10.3
|
||||
2. 10.2
|
||||
3. 10.1
|
||||
4. 9.6
|
||||
5. 9.5
|
||||
6. 9.4
|
||||
7. 9.3
|
||||
|
||||
js_task_runner:
|
||||
Select a JavaScript task runner. The choices are:
|
||||
|
||||
1. None
|
||||
2. Gulp_
|
||||
|
||||
custom_bootstrap_compilation:
|
||||
Indicates whether the project should support Bootstrap recompilation
|
||||
via the selected JavaScript task runner's task. This can be useful
|
||||
for real-time Bootstrap variable alteration.
|
||||
|
||||
use_compressor:
|
||||
Indicates whether the project should be configured to use `Django Compressor`_.
|
||||
|
||||
use_celery:
|
||||
Indicates whether the project should be configured to use Celery_.
|
||||
|
||||
use_mailhog:
|
||||
Indicates whether the project should be configured to use MailHog_.
|
||||
|
||||
use_sentry:
|
||||
Indicates whether the project should be configured to use Sentry_.
|
||||
|
||||
use_whitenoise:
|
||||
Indicates whether the project should be configured to use WhiteNoise_.
|
||||
|
||||
use_heroku:
|
||||
Indicates whether the project should be configured so as to be deployable
|
||||
to Heroku_.
|
||||
|
||||
use_travisci:
|
||||
Indicates whether the project should be configured to use `Travis CI`_.
|
||||
|
||||
keep_local_envs_in_vcs:
|
||||
Indicates whether the project's ``.envs/.local/`` should be kept in VCS
|
||||
(comes in handy when working in teams where local environment reproducibility
|
||||
is strongly encouraged).
|
||||
|
||||
debug:
|
||||
Indicates whether the project should be configured for debugging.
|
||||
This option is relevant for Cookiecutter Django developers only.
|
||||
|
||||
|
||||
.. _WhiteNoise: https://github.com/evansd/whitenoise
|
||||
.. _Celery: https://github.com/celery/celery
|
||||
.. _MailHog: https://github.com/mailhog/MailHog
|
||||
.. _Sentry: https://github.com/getsentry/sentry
|
||||
.. _Opbeat: https://github.com/opbeat/opbeat_python
|
||||
.. _PyCharm: https://www.jetbrains.com/pycharm/
|
||||
.. _Docker: https://github.com/docker/docker
|
||||
.. _Heroku: https://github.com/heroku/heroku-buildpack-python
|
||||
.. _Django Compressor: https://github.com/django-compressor/django-compressor
|
||||
.. _Gulp: https://github.com/gulpjs/gulp
|
||||
.. _Grunt: https://github.com/gruntjs/grunt
|
||||
.. _Webpack: https://github.com/webpack/webpack
|
||||
.. _Let's Encrypt: https://github.com/certbot/certbot
|
||||
.. _MIT: https://opensource.org/licenses/MIT
|
||||
.. _BSD: https://opensource.org/licenses/BSD-3-Clause
|
||||
.. _GPLv3: https://www.gnu.org/licenses/gpl.html
|
||||
.. _Apache Software License 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
.. _PyCharm: https://www.jetbrains.com/pycharm/
|
||||
|
||||
.. _Docker: https://github.com/docker/docker
|
||||
.. _Docker Compose: https://docs.docker.com/compose/
|
||||
|
||||
.. _PostgreSQL: https://www.postgresql.org/docs/
|
||||
|
||||
.. _Gulp: https://github.com/gulpjs/gulp
|
||||
|
||||
.. _Django Compressor: https://github.com/django-compressor/django-compressor
|
||||
|
||||
.. _Celery: https://github.com/celery/celery
|
||||
|
||||
.. _MailHog: https://github.com/mailhog/MailHog
|
||||
|
||||
.. _Sentry: https://github.com/getsentry/sentry
|
||||
|
||||
.. _WhiteNoise: https://github.com/evansd/whitenoise
|
||||
|
||||
.. _Heroku: https://github.com/heroku/heroku-buildpack-python
|
||||
|
||||
.. _Travis CI: https://travis-ci.org/
|
||||
|
|
|
@ -18,7 +18,7 @@ DJANGO_READ_DOT_ENV_FILE READ_DOT_ENV_FILE False
|
|||
======================================= =========================== ============================================== ======================================================================
|
||||
Environment Variable Django Setting Development Default Production Default
|
||||
======================================= =========================== ============================================== ======================================================================
|
||||
DJANGO_ADMIN_URL n/a r'^admin/' raises error
|
||||
DJANGO_ADMIN_URL n/a 'admin/' raises error
|
||||
DJANGO_CACHES CACHES (default) locmem redis
|
||||
DJANGO_DATABASES DATABASES (default) See code See code
|
||||
DJANGO_DEBUG DEBUG True False
|
||||
|
@ -44,17 +44,13 @@ Environment Variable Django Setting Development
|
|||
DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error
|
||||
DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error
|
||||
DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error
|
||||
DJANGO_SENTRY_DSN SENTRY_DSN n/a raises error
|
||||
SENTRY_DSN SENTRY_DSN n/a raises error
|
||||
DJANGO_SENTRY_CLIENT SENTRY_CLIENT n/a raven.contrib.django.raven_compat.DjangoClient
|
||||
DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a logging.INFO
|
||||
DJANGO_MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error
|
||||
DJANGO_MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error
|
||||
MAILGUN_SENDER_DOMAIN MAILGUN_SENDER_DOMAIN n/a raises error
|
||||
MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error
|
||||
MAILGUN_DOMAIN MAILGUN_SENDER_DOMAIN n/a raises error
|
||||
NEW_RELIC_APP_NAME NEW_RELIC_APP_NAME n/a raises error
|
||||
NEW_RELIC_LICENSE_KEY NEW_RELIC_LICENSE_KEY n/a raises error
|
||||
DJANGO_OPBEAT_APP_ID OPBEAT['APP_ID'] n/a raises error
|
||||
DJANGO_OPBEAT_SECRET_TOKEN OPBEAT['SECRET_TOKEN'] n/a raises error
|
||||
DJANGO_OPBEAT_ORGANIZATION_ID OPBEAT['ORGANIZATION_ID'] n/a raises error
|
||||
======================================= =========================== ============================================== ======================================================================
|
||||
|
||||
--------------------------
|
||||
|
|
|
@ -3,7 +3,10 @@ Troubleshooting
|
|||
|
||||
This page contains some advice about errors and problems commonly encountered during the development of Cookiecutter Django applications.
|
||||
|
||||
#. If you get the error ``jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'.`` , please upgrade your cookiecutter version to >= 1.4 (see issue # 528_ )
|
||||
#. ``project_slug`` must be a valid Python module name or you will have issues on imports.
|
||||
|
||||
.. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373
|
||||
#. ``jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'now'.``: please upgrade your cookiecutter version to >= 1.4 (see `#528`_)
|
||||
|
||||
#. Internal server error on user registration: make sure you have configured the mail backend (e.g. Mailgun) by adding the API key and sender domain
|
||||
|
||||
.. _#528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373
|
||||
|
|
|
@ -7,12 +7,12 @@ NOTE:
|
|||
|
||||
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import string
|
||||
import sys
|
||||
|
||||
try:
|
||||
# Inspired by
|
||||
|
@ -22,113 +22,81 @@ try:
|
|||
except NotImplementedError:
|
||||
using_sysrandom = False
|
||||
|
||||
PROJECT_DIR_PATH = os.path.realpath(os.path.curdir)
|
||||
TERMINATOR = "\x1b[0m"
|
||||
WARNING = "\x1b[1;33m [WARNING]: "
|
||||
INFO = "\x1b[1;33m [INFO]: "
|
||||
HINT = "\x1b[3;33m"
|
||||
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
||||
|
||||
DEBUG_VALUE = "debug"
|
||||
|
||||
|
||||
def remove_file(file_path):
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
|
||||
|
||||
def remove_open_source_project_only_files():
|
||||
file_names = [
|
||||
'CONTRIBUTORS.txt',
|
||||
]
|
||||
def remove_open_source_files():
|
||||
file_names = ["CONTRIBUTORS.txt"]
|
||||
for file_name in file_names:
|
||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_gplv3_files():
|
||||
file_names = [
|
||||
'COPYING',
|
||||
]
|
||||
file_names = ["COPYING"]
|
||||
for file_name in file_names:
|
||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_pycharm_files():
|
||||
idea_dir_path = os.path.join(PROJECT_DIR_PATH, '.idea')
|
||||
idea_dir_path = ".idea"
|
||||
if os.path.exists(idea_dir_path):
|
||||
shutil.rmtree(idea_dir_path)
|
||||
|
||||
docs_dir_path = os.path.join(PROJECT_DIR_PATH, 'docs', 'pycharm')
|
||||
docs_dir_path = os.path.join("docs", "pycharm")
|
||||
if os.path.exists(docs_dir_path):
|
||||
shutil.rmtree(docs_dir_path)
|
||||
|
||||
|
||||
def remove_docker_files():
|
||||
shutil.rmtree(os.path.join(PROJECT_DIR_PATH, 'compose'))
|
||||
shutil.rmtree("compose")
|
||||
|
||||
file_names = [
|
||||
'local.yml',
|
||||
'production.yml',
|
||||
'.dockerignore',
|
||||
]
|
||||
file_names = ["local.yml", "production.yml", ".dockerignore"]
|
||||
for file_name in file_names:
|
||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_heroku_files():
|
||||
file_names = [
|
||||
'Procfile',
|
||||
'runtime.txt',
|
||||
]
|
||||
file_names = ["Procfile", "runtime.txt", "requirements.txt"]
|
||||
for file_name in file_names:
|
||||
remove_file(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
|
||||
|
||||
def remove_paas_files():
|
||||
none_paas_files_left = True
|
||||
|
||||
if '{{ cookiecutter.use_heroku }}'.lower() == 'n':
|
||||
remove_heroku_files()
|
||||
none_paas_files_left &= True
|
||||
else:
|
||||
none_paas_files_left &= False
|
||||
|
||||
if none_paas_files_left:
|
||||
remove_file(os.path.join(PROJECT_DIR_PATH, 'requirements.txt'))
|
||||
|
||||
|
||||
def remove_grunt_files():
|
||||
file_names = [
|
||||
'Gruntfile.js',
|
||||
]
|
||||
for file_name in file_names:
|
||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_gulp_files():
|
||||
file_names = [
|
||||
'gulpfile.js',
|
||||
]
|
||||
file_names = ["gulpfile.js"]
|
||||
for file_name in file_names:
|
||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_packagejson_file():
|
||||
file_names = [
|
||||
'package.json',
|
||||
]
|
||||
file_names = ["package.json"]
|
||||
for file_name in file_names:
|
||||
os.remove(os.path.join(PROJECT_DIR_PATH, file_name))
|
||||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_celery_app():
|
||||
shutil.rmtree(os.path.join(PROJECT_DIR_PATH, '{{ cookiecutter.project_slug }}', 'taskapp'))
|
||||
shutil.rmtree(os.path.join("{{ cookiecutter.project_slug }}", "taskapp"))
|
||||
|
||||
|
||||
def remove_dottravisyml_file():
|
||||
os.remove(".travis.yml")
|
||||
|
||||
|
||||
def append_to_project_gitignore(path):
|
||||
gitignore_file_path = os.path.join(PROJECT_DIR_PATH, '.gitignore')
|
||||
with open(gitignore_file_path, 'a') as gitignore_file:
|
||||
gitignore_file_path = ".gitignore"
|
||||
with open(gitignore_file_path, "a") as gitignore_file:
|
||||
gitignore_file.write(path)
|
||||
gitignore_file.write(os.linesep)
|
||||
|
||||
|
||||
def generate_random_string(length,
|
||||
using_digits=False,
|
||||
using_ascii_letters=False,
|
||||
using_punctuation=False):
|
||||
def generate_random_string(
|
||||
length, using_digits=False, using_ascii_letters=False, using_punctuation=False
|
||||
):
|
||||
"""
|
||||
Example:
|
||||
opting out for 50 symbol-long, [a-z][A-Z][0-9] string
|
||||
|
@ -143,30 +111,26 @@ def generate_random_string(length,
|
|||
if using_ascii_letters:
|
||||
symbols += string.ascii_letters
|
||||
if using_punctuation:
|
||||
symbols += string.punctuation \
|
||||
.replace('"', '') \
|
||||
.replace("'", '') \
|
||||
.replace('\\', '')
|
||||
return ''.join([random.choice(symbols) for _ in range(length)])
|
||||
symbols += string.punctuation.replace('"', "").replace("'", "").replace(
|
||||
"\\", ""
|
||||
)
|
||||
return "".join([random.choice(symbols) for _ in range(length)])
|
||||
|
||||
|
||||
def set_flag(file_path,
|
||||
flag,
|
||||
value=None,
|
||||
*args,
|
||||
**kwargs):
|
||||
def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs):
|
||||
if value is None:
|
||||
random_string = generate_random_string(*args, **kwargs)
|
||||
if random_string is None:
|
||||
import sys
|
||||
sys.stdout.write(
|
||||
print(
|
||||
"We couldn't find a secure pseudo-random number generator on your system. "
|
||||
"Please, make sure to manually {} later.".format(flag)
|
||||
)
|
||||
random_string = flag
|
||||
if formatted is not None:
|
||||
random_string = formatted.format(random_string)
|
||||
value = random_string
|
||||
|
||||
with open(file_path, 'r+') as f:
|
||||
with open(file_path, "r+") as f:
|
||||
file_contents = f.read().replace(flag, value)
|
||||
f.seek(0)
|
||||
f.write(file_contents)
|
||||
|
@ -178,106 +142,151 @@ def set_flag(file_path,
|
|||
def set_django_secret_key(file_path):
|
||||
django_secret_key = set_flag(
|
||||
file_path,
|
||||
'!!!SET DJANGO_SECRET_KEY!!!',
|
||||
length=50,
|
||||
"!!!SET DJANGO_SECRET_KEY!!!",
|
||||
length=64,
|
||||
using_digits=True,
|
||||
using_ascii_letters=True
|
||||
using_ascii_letters=True,
|
||||
)
|
||||
return django_secret_key
|
||||
|
||||
|
||||
def set_postgres_user(file_path,
|
||||
value=None):
|
||||
def set_django_admin_url(file_path):
|
||||
django_admin_url = set_flag(
|
||||
file_path,
|
||||
"!!!SET DJANGO_ADMIN_URL!!!",
|
||||
formatted="{}/",
|
||||
length=32,
|
||||
using_digits=True,
|
||||
using_ascii_letters=True,
|
||||
)
|
||||
return django_admin_url
|
||||
|
||||
|
||||
def generate_postgres_user(debug=False):
|
||||
return DEBUG_VALUE if debug else generate_random_string(length=32, using_ascii_letters=True)
|
||||
|
||||
|
||||
def set_postgres_user(file_path, value):
|
||||
postgres_user = set_flag(
|
||||
file_path,
|
||||
'!!!SET POSTGRES_USER!!!',
|
||||
"!!!SET POSTGRES_USER!!!",
|
||||
value=value,
|
||||
length=8,
|
||||
using_ascii_letters=True
|
||||
)
|
||||
return postgres_user
|
||||
|
||||
|
||||
def set_postgres_password(file_path):
|
||||
def set_postgres_password(file_path, value=None):
|
||||
postgres_password = set_flag(
|
||||
file_path,
|
||||
'!!!SET POSTGRES_PASSWORD!!!',
|
||||
length=42,
|
||||
"!!!SET POSTGRES_PASSWORD!!!",
|
||||
value=value,
|
||||
length=64,
|
||||
using_digits=True,
|
||||
using_ascii_letters=True
|
||||
using_ascii_letters=True,
|
||||
)
|
||||
return postgres_password
|
||||
|
||||
|
||||
def initialize_dotenv(postgres_user):
|
||||
# Initializing `env.example` first.
|
||||
envexample_file_path = os.path.join(PROJECT_DIR_PATH, 'env.example')
|
||||
set_django_secret_key(envexample_file_path)
|
||||
set_postgres_user(envexample_file_path, value=postgres_user)
|
||||
set_postgres_password(envexample_file_path)
|
||||
# Renaming `env.example` to `.env`.
|
||||
dotenv_file_path = os.path.join(PROJECT_DIR_PATH, '.env')
|
||||
shutil.move(envexample_file_path, dotenv_file_path)
|
||||
def append_to_gitignore_file(s):
|
||||
with open(".gitignore", "a") as gitignore_file:
|
||||
gitignore_file.write(s)
|
||||
gitignore_file.write(os.linesep)
|
||||
|
||||
|
||||
def initialize_localyml(postgres_user):
|
||||
set_postgres_user(os.path.join(PROJECT_DIR_PATH, 'local.yml'), value=postgres_user)
|
||||
def set_flags_in_envs(postgres_user, debug=False):
|
||||
local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres")
|
||||
set_postgres_user(local_postgres_envs_path, value=postgres_user)
|
||||
set_postgres_password(local_postgres_envs_path, value=DEBUG_VALUE if debug else None)
|
||||
|
||||
production_django_envs_path = os.path.join(".envs", ".production", ".django")
|
||||
set_django_secret_key(production_django_envs_path)
|
||||
set_django_admin_url(production_django_envs_path)
|
||||
|
||||
production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres")
|
||||
set_postgres_user(production_postgres_envs_path, value=postgres_user)
|
||||
set_postgres_password(production_postgres_envs_path, value=DEBUG_VALUE if debug else None)
|
||||
|
||||
|
||||
def initialize_local_settings():
|
||||
set_django_secret_key(os.path.join(PROJECT_DIR_PATH, 'config', 'settings', 'local.py'))
|
||||
def set_flags_in_settings_files():
|
||||
set_django_secret_key(os.path.join("config", "settings", "local.py"))
|
||||
set_django_secret_key(os.path.join("config", "settings", "test.py"))
|
||||
|
||||
|
||||
def initialize_test_settings():
|
||||
set_django_secret_key(os.path.join(PROJECT_DIR_PATH, 'config', 'settings', 'test.py'))
|
||||
def remove_envs_and_associated_files():
|
||||
shutil.rmtree(".envs")
|
||||
os.remove("merge_production_dotenvs_in_dotenv.py")
|
||||
|
||||
|
||||
def remove_celery_compose_dirs():
|
||||
shutil.rmtree(os.path.join("compose", "local", "django", "celery"))
|
||||
shutil.rmtree(os.path.join("compose", "production", "django", "celery"))
|
||||
|
||||
|
||||
def main():
|
||||
postgres_user = generate_random_string(length=16, using_ascii_letters=True)
|
||||
initialize_dotenv(postgres_user)
|
||||
initialize_localyml(postgres_user)
|
||||
initialize_local_settings()
|
||||
initialize_test_settings()
|
||||
postgres_user = generate_postgres_user(debug="{{ cookiecutter.debug }}".lower() == "y")
|
||||
set_flags_in_envs(postgres_user, debug="{{ cookiecutter.debug }}".lower() == "y")
|
||||
set_flags_in_settings_files()
|
||||
|
||||
if '{{ cookiecutter.open_source_license }}' == 'Not open source':
|
||||
remove_open_source_project_only_files()
|
||||
elif '{{ cookiecutter.open_source_license}}' != 'GPLv3':
|
||||
if "{{ cookiecutter.open_source_license }}" == "Not open source":
|
||||
remove_open_source_files()
|
||||
if "{{ cookiecutter.open_source_license}}" != "GPLv3":
|
||||
remove_gplv3_files()
|
||||
|
||||
if '{{ cookiecutter.use_pycharm }}'.lower() == 'n':
|
||||
if "{{ cookiecutter.use_pycharm }}".lower() == "n":
|
||||
remove_pycharm_files()
|
||||
|
||||
if '{{ cookiecutter.use_docker }}'.lower() == 'n':
|
||||
if "{{ cookiecutter.use_docker }}".lower() == "n":
|
||||
remove_docker_files()
|
||||
|
||||
remove_paas_files()
|
||||
if "{{ cookiecutter.use_heroku }}".lower() == "n":
|
||||
remove_heroku_files()
|
||||
|
||||
if '{{ cookiecutter.js_task_runner}}'.lower() == 'gulp':
|
||||
remove_grunt_files()
|
||||
elif '{{ cookiecutter.js_task_runner}}'.lower() == 'grunt':
|
||||
remove_gulp_files()
|
||||
if (
|
||||
"{{ cookiecutter.use_docker }}".lower() == "n"
|
||||
and "{{ cookiecutter.use_heroku }}".lower() == "n"
|
||||
):
|
||||
if "{{ cookiecutter.keep_local_envs_in_vcs }}".lower() == "y":
|
||||
print(
|
||||
INFO + ".env(s) are only utilized when Docker Compose and/or "
|
||||
"Heroku support is enabled so keeping them does not "
|
||||
"make sense given your current setup." + TERMINATOR
|
||||
)
|
||||
remove_envs_and_associated_files()
|
||||
else:
|
||||
remove_gulp_files()
|
||||
remove_grunt_files()
|
||||
remove_packagejson_file()
|
||||
append_to_gitignore_file(".env")
|
||||
append_to_gitignore_file(".envs/*")
|
||||
if "{{ cookiecutter.keep_local_envs_in_vcs }}".lower() == "y":
|
||||
append_to_gitignore_file("!.envs/.local/")
|
||||
|
||||
if '{{ cookiecutter.js_task_runner }}'.lower() in ['grunt', 'gulp'] \
|
||||
and '{{ cookiecutter.use_docker }}'.lower() == 'y':
|
||||
TERMINATOR = "\x1b[0m"
|
||||
INFO = "\x1b[1;33m [INFO]: "
|
||||
sys.stdout.write(
|
||||
INFO +
|
||||
"Docker and {} JS task runner ".format('{{ cookiecutter.js_task_runner }}'.lower().capitalize()) +
|
||||
"working together not supported yet. "
|
||||
"You can continue using the generated project like you normally would, "
|
||||
"however you would need to add a JS task runner service "
|
||||
"to your Docker Compose configuration manually." +
|
||||
TERMINATOR
|
||||
if "{{ cookiecutter.js_task_runner}}".lower() == "none":
|
||||
remove_gulp_files()
|
||||
remove_packagejson_file()
|
||||
if (
|
||||
"{{ cookiecutter.js_task_runner }}".lower() != "none"
|
||||
and "{{ cookiecutter.use_docker }}".lower() == "y"
|
||||
):
|
||||
print(
|
||||
WARNING
|
||||
+ "Docker and {} JS task runner ".format(
|
||||
"{{ cookiecutter.js_task_runner }}".lower().capitalize()
|
||||
)
|
||||
+ "working together not supported yet. "
|
||||
"You can continue using the generated project like you "
|
||||
"normally would, however you would need to add a JS "
|
||||
"task runner service to your Docker Compose configuration "
|
||||
"manually." + TERMINATOR
|
||||
)
|
||||
|
||||
if '{{ cookiecutter.use_celery }}'.lower() == 'n':
|
||||
if "{{ cookiecutter.use_celery }}".lower() == "n":
|
||||
remove_celery_app()
|
||||
if "{{ cookiecutter.use_docker }}".lower() == "y":
|
||||
remove_celery_compose_dirs()
|
||||
|
||||
if "{{ cookiecutter.use_travisci }}".lower() == "n":
|
||||
remove_dottravisyml_file()
|
||||
|
||||
print(SUCCESS + "Project initialized, keep up the good work!" + TERMINATOR)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -6,54 +6,51 @@ NOTE:
|
|||
|
||||
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
project_slug = '{{ cookiecutter.project_slug }}'
|
||||
if hasattr(project_slug, 'isidentifier'):
|
||||
assert project_slug.isidentifier(), "'{}' project slug is not a valid Python identifier.".format(project_slug)
|
||||
import sys
|
||||
|
||||
using_docker = '{{ cookiecutter.use_docker }}'.lower()
|
||||
if using_docker == 'n':
|
||||
TERMINATOR = "\x1b[0m"
|
||||
WARNING = "\x1b[1;33m [WARNING]: "
|
||||
INFO = "\x1b[1;33m [INFO]: "
|
||||
HINT = "\x1b[3;33m"
|
||||
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
||||
TERMINATOR = "\x1b[0m"
|
||||
WARNING = "\x1b[1;33m [WARNING]: "
|
||||
INFO = "\x1b[1;33m [INFO]: "
|
||||
HINT = "\x1b[3;33m"
|
||||
SUCCESS = "\x1b[1;32m [SUCCESS]: "
|
||||
|
||||
import sys
|
||||
project_slug = "{{ cookiecutter.project_slug }}"
|
||||
if hasattr(project_slug, "isidentifier"):
|
||||
assert project_slug.isidentifier(), "'{}' project slug is not a valid Python identifier.".format(
|
||||
project_slug
|
||||
)
|
||||
|
||||
assert "\\" not in "{{ cookiecutter.author_name }}", "Don't include backslashes in author name."
|
||||
|
||||
if "{{ cookiecutter.use_docker }}".lower() == "n":
|
||||
python_major_version = sys.version_info[0]
|
||||
if python_major_version == 2:
|
||||
sys.stdout.write(
|
||||
WARNING +
|
||||
"Cookiecutter Django does not support Python 2. "
|
||||
print(
|
||||
WARNING + "Cookiecutter Django does not support Python 2. "
|
||||
"Stability is guaranteed with Python 3.6+ only, "
|
||||
"are you sure you want to proceed (y/n)? " +
|
||||
TERMINATOR
|
||||
"are you sure you want to proceed (y/n)? " + TERMINATOR
|
||||
)
|
||||
yes_options, no_options = frozenset(['y']), frozenset(['n'])
|
||||
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
|
||||
while True:
|
||||
choice = raw_input().lower()
|
||||
if choice in yes_options:
|
||||
break
|
||||
|
||||
elif choice in no_options:
|
||||
sys.stdout.write(
|
||||
INFO +
|
||||
"Generation process stopped as requested." +
|
||||
TERMINATOR
|
||||
)
|
||||
print(INFO + "Generation process stopped as requested." + TERMINATOR)
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.stdout.write(
|
||||
HINT +
|
||||
"Please respond with {} or {}: ".format(
|
||||
', '.join(["'{}'".format(o) for o in yes_options if not o == '']),
|
||||
', '.join(["'{}'".format(o) for o in no_options if not o == ''])
|
||||
) +
|
||||
TERMINATOR
|
||||
print(
|
||||
HINT
|
||||
+ "Please respond with {} or {}: ".format(
|
||||
", ".join(
|
||||
["'{}'".format(o) for o in yes_options if not o == ""]
|
||||
),
|
||||
", ".join(
|
||||
["'{}'".format(o) for o in no_options if not o == ""]
|
||||
),
|
||||
)
|
||||
+ TERMINATOR
|
||||
)
|
||||
|
||||
sys.stdout.write(
|
||||
SUCCESS +
|
||||
"Project initialized, keep up the good work!" +
|
||||
TERMINATOR
|
||||
)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[tool:pytest]
|
||||
[pytest]
|
||||
python_paths = .
|
||||
norecursedirs = .tox .git */migrations/* */static/* docs venv */{{cookiecutter.project_slug}}/*
|
|
@ -1,11 +1,13 @@
|
|||
cookiecutter==1.6.0
|
||||
flake8==3.5.0 # pyup: != 2.6.0
|
||||
sh==1.12.14
|
||||
binaryornot==0.4.4
|
||||
|
||||
# Code quality
|
||||
# ------------------------------------------------------------------------------
|
||||
flake8==3.5.0
|
||||
|
||||
# Testing
|
||||
pytest==3.3.2
|
||||
pycodestyle==2.3.1
|
||||
pyflakes==1.6.0
|
||||
tox==2.9.1
|
||||
# ------------------------------------------------------------------------------
|
||||
tox==3.0.0
|
||||
pytest==3.6.1
|
||||
pytest-cookies==0.3.0
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
# These requirements prevented an upgrade to Django 1.11.
|
||||
django-autoslug==1.9.3
|
47
setup.py
47
setup.py
|
@ -10,43 +10,42 @@ except ImportError:
|
|||
|
||||
# Our version ALWAYS matches the version of Django we support
|
||||
# If Django has a new release, we branch, tag, then update this setting after the tag.
|
||||
version = '1.11.9'
|
||||
version = "2.0.2"
|
||||
|
||||
if sys.argv[-1] == 'tag':
|
||||
if sys.argv[-1] == "tag":
|
||||
os.system('git tag -a %s -m "version %s"' % (version, version))
|
||||
os.system('git push --tags')
|
||||
os.system("git push --tags")
|
||||
sys.exit()
|
||||
|
||||
with open('README.rst') as readme_file:
|
||||
with open("README.rst") as readme_file:
|
||||
long_description = readme_file.read()
|
||||
|
||||
setup(
|
||||
name='cookiecutter-django',
|
||||
name="cookiecutter-django",
|
||||
version=version,
|
||||
description='A Cookiecutter template for creating production-ready Django projects quickly.',
|
||||
description="A Cookiecutter template for creating production-ready Django projects quickly.",
|
||||
long_description=long_description,
|
||||
author='Daniel Roy Greenfeld',
|
||||
author_email='pydanny@gmail.com',
|
||||
url='https://github.com/pydanny/cookiecutter-django',
|
||||
author="Daniel Roy Greenfeld",
|
||||
author_email="pydanny@gmail.com",
|
||||
url="https://github.com/pydanny/cookiecutter-django",
|
||||
packages=[],
|
||||
license='BSD',
|
||||
license="BSD",
|
||||
zip_safe=False,
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Environment :: Console',
|
||||
'Framework :: Django :: 1.11',
|
||||
'Intended Audience :: Developers',
|
||||
'Natural Language :: English',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Software Development',
|
||||
"Development Status :: 4 - Beta",
|
||||
"Environment :: Console",
|
||||
"Framework :: Django :: 2.0",
|
||||
"Intended Audience :: Developers",
|
||||
"Natural Language :: English",
|
||||
"License :: OSI Approved :: BSD License",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Topic :: Software Development",
|
||||
],
|
||||
keywords=(
|
||||
'cookiecutter, Python, projects, project templates, django, '
|
||||
'skeleton, scaffolding, project directory, setup.py'
|
||||
"cookiecutter, Python, projects, project templates, django, "
|
||||
"skeleton, scaffolding, project directory, setup.py"
|
||||
),
|
||||
)
|
||||
|
|
|
@ -5,21 +5,21 @@ import sh
|
|||
import pytest
|
||||
from binaryornot.check import is_binary
|
||||
|
||||
PATTERN = '{{(\s?cookiecutter)[.](.*?)}}'
|
||||
PATTERN = "{{(\s?cookiecutter)[.](.*?)}}"
|
||||
RE_OBJ = re.compile(PATTERN)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def context():
|
||||
return {
|
||||
'project_name': 'My Test Project',
|
||||
'project_slug': 'my_test_project',
|
||||
'author_name': 'Test Author',
|
||||
'email': 'test@example.com',
|
||||
'description': 'A short description of the project.',
|
||||
'domain_name': 'example.com',
|
||||
'version': '0.1.0',
|
||||
'timezone': 'UTC',
|
||||
"project_name": "My Test Project",
|
||||
"project_slug": "my_test_project",
|
||||
"author_name": "Test Author",
|
||||
"email": "test@example.com",
|
||||
"description": "A short description of the project.",
|
||||
"domain_name": "example.com",
|
||||
"version": "0.1.0",
|
||||
"timezone": "UTC",
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,9 +40,10 @@ def check_paths(paths):
|
|||
for path in paths:
|
||||
if is_binary(path):
|
||||
continue
|
||||
for line in open(path, 'r'):
|
||||
|
||||
for line in open(path, "r"):
|
||||
match = RE_OBJ.search(line)
|
||||
msg = 'cookiecutter variable not replaced in {}'
|
||||
msg = "cookiecutter variable not replaced in {}"
|
||||
assert match is None, msg.format(path)
|
||||
|
||||
|
||||
|
@ -50,7 +51,7 @@ def test_default_configuration(cookies, context):
|
|||
result = cookies.bake(extra_context=context)
|
||||
assert result.exit_code == 0
|
||||
assert result.exception is None
|
||||
assert result.project.basename == context['project_slug']
|
||||
assert result.project.basename == context["project_slug"]
|
||||
assert result.project.isdir()
|
||||
|
||||
paths = build_files_list(str(result.project))
|
||||
|
@ -58,9 +59,9 @@ def test_default_configuration(cookies, context):
|
|||
check_paths(paths)
|
||||
|
||||
|
||||
@pytest.fixture(params=['use_mailhog', 'use_celery', 'windows'])
|
||||
@pytest.fixture(params=["use_mailhog", "use_celery", "windows"])
|
||||
def feature_context(request, context):
|
||||
context.update({request.param: 'y'})
|
||||
context.update({request.param: "y"})
|
||||
return context
|
||||
|
||||
|
||||
|
@ -68,7 +69,7 @@ def test_enabled_features(cookies, feature_context):
|
|||
result = cookies.bake(extra_context=feature_context)
|
||||
assert result.exit_code == 0
|
||||
assert result.exception is None
|
||||
assert result.project.basename == feature_context['project_slug']
|
||||
assert result.project.basename == feature_context["project_slug"]
|
||||
assert result.project.isdir()
|
||||
|
||||
paths = build_files_list(str(result.project))
|
||||
|
|
|
@ -11,11 +11,14 @@ mkdir -p .cache/docker
|
|||
cd .cache/docker
|
||||
|
||||
# create the project using the default settings in cookiecutter.json
|
||||
cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y js_task_runner=None
|
||||
cd project_name
|
||||
cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y
|
||||
cd my_awesome_project
|
||||
|
||||
# run the project's tests
|
||||
docker-compose -f local.yml run django python manage.py test
|
||||
|
||||
# return non-zero status code if there are migrations that have not been created
|
||||
docker-compose -f local.yml run django python manage.py makemigrations --dry-run --check || { echo "ERROR: there were changes in the models, but migration listed above have not been created and are not saved in version control"; exit 1; }
|
||||
|
||||
# Test support for translations
|
||||
docker-compose -f local.yml run django python manage.py makemessages
|
||||
|
|
9
tox.ini
9
tox.ini
|
@ -3,10 +3,5 @@ skipsdist = true
|
|||
envlist = py36
|
||||
|
||||
[testenv]
|
||||
passenv = LC_ALL, LANG, HOME
|
||||
deps =
|
||||
binaryornot
|
||||
flake8==2.5.5
|
||||
pytest-cookies
|
||||
sh
|
||||
commands = py.test {posargs:tests}
|
||||
deps = -rrequirements.txt
|
||||
commands = pytest {posargs:./tests}
|
||||
|
|
7
{{cookiecutter.project_slug}}/.envs/.local/.django
Normal file
7
{{cookiecutter.project_slug}}/.envs/.local/.django
Normal file
|
@ -0,0 +1,7 @@
|
|||
# General
|
||||
# ------------------------------------------------------------------------------
|
||||
USE_DOCKER=yes
|
||||
|
||||
# Redis
|
||||
# ------------------------------------------------------------------------------
|
||||
REDIS_URL=redis://redis:6379/0
|
7
{{cookiecutter.project_slug}}/.envs/.local/.postgres
Normal file
7
{{cookiecutter.project_slug}}/.envs/.local/.postgres
Normal file
|
@ -0,0 +1,7 @@
|
|||
# PostgreSQL
|
||||
# ------------------------------------------------------------------------------
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB={{ cookiecutter.project_slug }}
|
||||
POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!!
|
3
{{cookiecutter.project_slug}}/.envs/.production/.caddy
Normal file
3
{{cookiecutter.project_slug}}/.envs/.production/.caddy
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Caddy
|
||||
# ------------------------------------------------------------------------------
|
||||
DOMAIN_NAME={{ cookiecutter.domain_name }}
|
45
{{cookiecutter.project_slug}}/.envs/.production/.django
Normal file
45
{{cookiecutter.project_slug}}/.envs/.production/.django
Normal file
|
@ -0,0 +1,45 @@
|
|||
# General
|
||||
# ------------------------------------------------------------------------------
|
||||
# DJANGO_READ_DOT_ENV_FILE=True
|
||||
DJANGO_SETTINGS_MODULE=config.settings.production
|
||||
DJANGO_SECRET_KEY=!!!SET DJANGO_SECRET_KEY!!!
|
||||
DJANGO_ADMIN_URL=!!!SET DJANGO_ADMIN_URL!!!
|
||||
DJANGO_ALLOWED_HOSTS=.{{ cookiecutter.domain_name }}
|
||||
|
||||
# Security
|
||||
# ------------------------------------------------------------------------------
|
||||
# TIP: better off using DNS, however, redirect is OK too
|
||||
DJANGO_SECURE_SSL_REDIRECT=False
|
||||
|
||||
# Email
|
||||
# ------------------------------------------------------------------------------
|
||||
MAILGUN_API_KEY=
|
||||
DJANGO_SERVER_EMAIL=
|
||||
MAILGUN_DOMAIN=
|
||||
|
||||
# AWS
|
||||
# ------------------------------------------------------------------------------
|
||||
DJANGO_AWS_ACCESS_KEY_ID=
|
||||
DJANGO_AWS_SECRET_ACCESS_KEY=
|
||||
DJANGO_AWS_STORAGE_BUCKET_NAME=
|
||||
|
||||
# django-allauth
|
||||
# ------------------------------------------------------------------------------
|
||||
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True
|
||||
{% if cookiecutter.use_compressor == 'y' %}
|
||||
# django-compressor
|
||||
# ------------------------------------------------------------------------------
|
||||
COMPRESS_ENABLED=
|
||||
{% endif %}
|
||||
# Gunicorn
|
||||
# ------------------------------------------------------------------------------
|
||||
WEB_CONCURRENCY=4
|
||||
{% if cookiecutter.use_sentry == 'y' %}
|
||||
# Sentry
|
||||
# ------------------------------------------------------------------------------
|
||||
SENTRY_DSN=
|
||||
{% endif %}
|
||||
|
||||
# Redis
|
||||
# ------------------------------------------------------------------------------
|
||||
REDIS_URL=redis://redis:6379/0
|
|
@ -0,0 +1,7 @@
|
|||
# PostgreSQL
|
||||
# ------------------------------------------------------------------------------
|
||||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB={{ cookiecutter.project_slug }}
|
||||
POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!!
|
40
{{cookiecutter.project_slug}}/.gitignore
vendored
40
{{cookiecutter.project_slug}}/.gitignore
vendored
|
@ -53,42 +53,25 @@ coverage.xml
|
|||
# Django stuff:
|
||||
staticfiles/
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
{% if cookiecutter.use_celery == 'y' -%}
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
{%- endif %}
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
|
@ -122,9 +105,6 @@ coverage
|
|||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
|
@ -341,7 +321,7 @@ Session.vim
|
|||
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
|
||||
{% if cookiecutter.use_docker == 'n' %}
|
||||
|
||||
### VirtualEnv template
|
||||
# Virtualenv
|
||||
|
@ -354,16 +334,12 @@ tags
|
|||
[Ss]cripts
|
||||
pyvenv.cfg
|
||||
pip-selfcheck.json
|
||||
|
||||
|
||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%}
|
||||
mailhog
|
||||
{% endif %}
|
||||
|
||||
### Project template
|
||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
||||
MailHog
|
||||
{%- endif %}
|
||||
{{ cookiecutter.project_slug }}/media/
|
||||
|
||||
{% if cookiecutter.use_docker == 'y' -%}
|
||||
# Added to maintain local compose files which are ignored by something above.
|
||||
# See issue https://github.com/pydanny/cookiecutter-django/issues/1321
|
||||
!/compose/local/
|
||||
{% endif %}
|
||||
.pytest_cache/
|
||||
|
|
6
{{cookiecutter.project_slug}}/.idea/misc.xml
Normal file
6
{{cookiecutter.project_slug}}/.idea/misc.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
8
{{cookiecutter.project_slug}}/.idea/modules.xml
Normal file
8
{{cookiecutter.project_slug}}/.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/{{ cookiecutter.project_slug }}.iml" filepath="$PROJECT_DIR$/.idea/{{ cookiecutter.project_slug }}.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,33 +0,0 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: runserver" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="launchJavascriptDebuger" value="false" />
|
||||
<option name="port" value="8000" />
|
||||
<option name="host" value="0.0.0.0" />
|
||||
<option name="additionalOptions" value="" />
|
||||
<option name="browserUrl" value="" />
|
||||
<option name="runTestServer" value="false" />
|
||||
<option name="runNoReload" value="false" />
|
||||
<option name="useCustomRunCommand" value="false" />
|
||||
<option name="customRunCommand" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,21 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="merge_production_dotenvs_in_dotenv" type="PythonConfigurationType" factoryName="Python" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="merge_production_dotenvs_in_dotenv.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: migrate" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<configuration default="false" name="migrate" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
|
@ -0,0 +1,33 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="runserver" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="launchJavascriptDebuger" value="false" />
|
||||
<option name="port" value="8000" />
|
||||
<option name="host" value="0.0.0.0" />
|
||||
<option name="additionalOptions" value="" />
|
||||
<option name="browserUrl" value="" />
|
||||
<option name="runTestServer" value="false" />
|
||||
<option name="runNoReload" value="false" />
|
||||
<option name="useCustomRunCommand" value="false" />
|
||||
<option name="customRunCommand" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: runserver_plus" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<configuration default="false" name="runserver_plus" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - all" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<configuration default="false" name="tests - all" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.test" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - class: TestUser" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<configuration default="false" name="tests - class: TestUser" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.test" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - file: test_models" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<configuration default="false" name="tests - file: test_models" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.test" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - module: users" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<configuration default="false" name="tests - module: users" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.test" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
|
@ -1,17 +1,17 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - specific: test_get_absolute_url" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<configuration default="false" name="tests - specific: test_get_absolute_url" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.test" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://[$PROJECT_DIR$/local.yml]:django/python" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.project_slug }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
|
@ -3,4 +3,4 @@
|
|||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -5,19 +5,32 @@
|
|||
<configuration>
|
||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||
<option name="settingsModule" value="config/settings/local.py" />
|
||||
<option name="manageScript" value="manage.py" />
|
||||
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
||||
<option name="environment" value="<map/>" />
|
||||
<option name="doNotUseTestRunner" value="false" />
|
||||
<option name="trackFilePattern" value="migrations" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
{% if cookiecutter.js_task_runner != 'None' %}
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
|
||||
</content>
|
||||
{% else %}
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
{% endif %}
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PackageRequirementsSettings">
|
||||
<option name="requirementsPath" value="$MODULE_DIR$/requirements/local.txt" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="renderExternalDocumentation" value="true" />
|
||||
</component>
|
||||
<component name="ReSTService">
|
||||
<option name="workdir" value="$MODULE_DIR$/docs" />
|
||||
<option name="DOC_DIR" value="$MODULE_DIR$/docs" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
|
@ -31,4 +44,4 @@
|
|||
<option name="projectConfiguration" value="py.test" />
|
||||
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
||||
</component>
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
module.exports = function (grunt) {
|
||||
|
||||
var appConfig = grunt.file.readJSON('package.json');
|
||||
|
||||
// Load grunt tasks automatically
|
||||
// see: https://github.com/sindresorhus/load-grunt-tasks
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
// Time how long tasks take. Can help when optimizing build times
|
||||
// see: https://npmjs.org/package/time-grunt
|
||||
require('time-grunt')(grunt);
|
||||
|
||||
var pathsConfig = function (appName) {
|
||||
this.app = appName || appConfig.name;
|
||||
|
||||
return {
|
||||
app: this.app,
|
||||
templates: this.app + '/templates',
|
||||
css: this.app + '/static/css',
|
||||
sass: this.app + '/static/sass',
|
||||
fonts: this.app + '/static/fonts',
|
||||
images: this.app + '/static/images',
|
||||
js: this.app + '/static/js',
|
||||
manageScript: 'manage.py',
|
||||
}
|
||||
};
|
||||
|
||||
grunt.initConfig({
|
||||
|
||||
paths: pathsConfig(),
|
||||
pkg: appConfig,
|
||||
|
||||
// see: https://github.com/gruntjs/grunt-contrib-watch
|
||||
watch: {
|
||||
gruntfile: {
|
||||
files: ['Gruntfile.js']
|
||||
},
|
||||
sass: {
|
||||
files: ['<%= paths.sass %>/**/*.{scss,sass}'],
|
||||
tasks: ['sass:dev'],
|
||||
options: {
|
||||
atBegin: true
|
||||
}
|
||||
},
|
||||
livereload: {
|
||||
files: [
|
||||
'<%= paths.js %>/**/*.js',
|
||||
'<%= paths.sass %>/**/*.{scss,sass}',
|
||||
'<%= paths.app %>/**/*.html'
|
||||
],
|
||||
options: {
|
||||
spawn: false,
|
||||
livereload: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// see: https://github.com/sindresorhus/grunt-sass
|
||||
sass: {
|
||||
dev: {
|
||||
options: {
|
||||
outputStyle: 'nested',
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
includePaths: ['node_modules/bootstrap/scss'],
|
||||
{% endif %}
|
||||
sourceMap: false,
|
||||
precision: 10
|
||||
},
|
||||
files: {
|
||||
'<%= paths.css %>/project.css': '<%= paths.sass %>/project.scss'
|
||||
},
|
||||
},
|
||||
dist: {
|
||||
options: {
|
||||
outputStyle: 'compressed',
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
includePaths: ['node_modules/bootstrap/scss'],
|
||||
{% endif %}
|
||||
sourceMap: false,
|
||||
precision: 10
|
||||
},
|
||||
files: {
|
||||
'<%= paths.css %>/project.css': '<%= paths.sass %>/project.scss'
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
//see https://github.com/nDmitry/grunt-postcss
|
||||
postcss: {
|
||||
options: {
|
||||
map: true, // inline sourcemaps
|
||||
|
||||
processors: [
|
||||
require('pixrem')(), // add fallbacks for rem units
|
||||
require('autoprefixer-core')({browsers: [
|
||||
'Android 2.3',
|
||||
'Android >= 4',
|
||||
'Chrome >= 20',
|
||||
'Firefox >= 24',
|
||||
'Explorer >= 8',
|
||||
'iOS >= 6',
|
||||
'Opera >= 12',
|
||||
'Safari >= 6'
|
||||
]}), // add vendor prefixes
|
||||
require('cssnano')() // minify the result
|
||||
]
|
||||
},
|
||||
dist: {
|
||||
src: '<%= paths.css %>/*.css'
|
||||
}
|
||||
},
|
||||
|
||||
// see: https://npmjs.org/package/grunt-bg-shell
|
||||
bgShell: {
|
||||
_defaults: {
|
||||
bg: true
|
||||
},
|
||||
runDjango: {
|
||||
cmd: 'python <%= paths.manageScript %> runserver'
|
||||
},
|
||||
{% if cookiecutter.use_mailhog == "y" and cookiecutter.use_docker == 'n' -%}runMailHog: {
|
||||
cmd: './mailhog'
|
||||
},{%- endif %}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('serve', [
|
||||
{% if cookiecutter.use_mailhog == "y" and cookiecutter.use_docker == 'n' -%}
|
||||
'bgShell:runMailHog',
|
||||
{%- endif %}
|
||||
'bgShell:runDjango',
|
||||
'watch'
|
||||
]);
|
||||
|
||||
grunt.registerTask('build', [
|
||||
'sass:dist',
|
||||
'postcss'
|
||||
]);
|
||||
|
||||
grunt.registerTask('default', [
|
||||
'build'
|
||||
]);
|
||||
|
||||
};
|
|
@ -99,7 +99,7 @@ The email server will exit when you exit the Grunt task on the CLI with Ctrl+C.
|
|||
{% endif %}
|
||||
.. _mailhog: https://github.com/mailhog/MailHog
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == "y" %}
|
||||
{% if cookiecutter.use_sentry == "y" %}
|
||||
|
||||
Sentry
|
||||
^^^^^^
|
||||
|
|
|
@ -1,27 +1,40 @@
|
|||
FROM python:3.6
|
||||
FROM python:3.6-alpine
|
||||
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# Requirements have to be pulled and installed here, otherwise caching won't work
|
||||
RUN apk update \
|
||||
# psycopg2 dependencies
|
||||
&& apk add --virtual build-deps gcc python3-dev musl-dev \
|
||||
&& apk add postgresql-dev \
|
||||
# Pillow dependencies
|
||||
&& apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
|
||||
# CFFI dependencies
|
||||
&& apk add libffi-dev py-cffi \
|
||||
# Translations dependencies
|
||||
&& apk add gettext \
|
||||
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
|
||||
&& apk add postgresql-client
|
||||
|
||||
# Requirements are installed here to ensure they will be cached.
|
||||
COPY ./requirements /requirements
|
||||
RUN pip install -r /requirements/local.txt
|
||||
|
||||
COPY ./compose/production/django/entrypoint.sh /entrypoint.sh
|
||||
RUN sed -i 's/\r//' /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
COPY ./compose/production/django/entrypoint /entrypoint
|
||||
RUN sed -i 's/\r//' /entrypoint
|
||||
RUN chmod +x /entrypoint
|
||||
|
||||
COPY ./compose/local/django/start.sh /start.sh
|
||||
RUN sed -i 's/\r//' /start.sh
|
||||
RUN chmod +x /start.sh
|
||||
|
||||
COPY ./compose/local/django/celery/worker/start.sh /start-celeryworker.sh
|
||||
RUN sed -i 's/\r//' /start-celeryworker.sh
|
||||
RUN chmod +x /start-celeryworker.sh
|
||||
|
||||
COPY ./compose/local/django/celery/beat/start.sh /start-celerybeat.sh
|
||||
RUN sed -i 's/\r//' /start-celerybeat.sh
|
||||
RUN chmod +x /start-celerybeat.sh
|
||||
COPY ./compose/local/django/start /start
|
||||
RUN sed -i 's/\r//' /start
|
||||
RUN chmod +x /start
|
||||
{% if cookiecutter.use_celery == "y" %}
|
||||
COPY ./compose/local/django/celery/worker/start /start-celeryworker
|
||||
RUN sed -i 's/\r//' /start-celeryworker
|
||||
RUN chmod +x /start-celeryworker
|
||||
|
||||
COPY ./compose/local/django/celery/beat/start /start-celerybeat
|
||||
RUN sed -i 's/\r//' /start-celerybeat
|
||||
RUN chmod +x /start-celerybeat
|
||||
{% endif %}
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
ENTRYPOINT ["/entrypoint"]
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
set -o xtrace
|
||||
|
||||
|
||||
rm -f './celerybeat.pid'
|
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
set -o xtrace
|
||||
|
||||
|
||||
celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
set -o xtrace
|
||||
|
||||
|
||||
python manage.py migrate
|
|
@ -1,3 +1,3 @@
|
|||
FROM abiosoft/caddy:0.10.6
|
||||
FROM abiosoft/caddy:0.11.0
|
||||
|
||||
COPY ./compose/production/caddy/Caddyfile /etc/Caddyfile
|
||||
|
|
|
@ -1,33 +1,44 @@
|
|||
FROM python:3.6
|
||||
FROM python:3.6-alpine
|
||||
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
RUN groupadd -r django \
|
||||
&& useradd -r -g django django
|
||||
RUN apk update \
|
||||
# psycopg2 dependencies
|
||||
&& apk add --virtual build-deps gcc python3-dev musl-dev \
|
||||
&& apk add postgresql-dev \
|
||||
# Pillow dependencies
|
||||
&& apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
|
||||
# CFFI dependencies
|
||||
&& apk add libffi-dev py-cffi
|
||||
|
||||
# Requirements have to be pulled and installed here, otherwise caching won't work
|
||||
RUN addgroup -S django \
|
||||
&& adduser -S -G django django
|
||||
|
||||
# Requirements are installed here to ensure they will be cached.
|
||||
COPY ./requirements /requirements
|
||||
RUN pip install --no-cache-dir -r /requirements/production.txt \
|
||||
&& rm -rf /requirements
|
||||
|
||||
COPY ./compose/production/django/gunicorn.sh /gunicorn.sh
|
||||
RUN sed -i 's/\r//' /gunicorn.sh
|
||||
RUN chmod +x /gunicorn.sh
|
||||
RUN chown django /gunicorn.sh
|
||||
COPY ./compose/production/django/entrypoint /entrypoint
|
||||
RUN sed -i 's/\r//' /entrypoint
|
||||
RUN chmod +x /entrypoint
|
||||
RUN chown django /entrypoint
|
||||
|
||||
COPY ./compose/production/django/entrypoint.sh /entrypoint.sh
|
||||
RUN sed -i 's/\r//' /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
RUN chown django /entrypoint.sh
|
||||
|
||||
COPY ./compose/production/django/celery/worker/start.sh /start-celeryworker.sh
|
||||
RUN sed -i 's/\r//' /start-celeryworker.sh
|
||||
RUN chmod +x /start-celeryworker.sh
|
||||
|
||||
COPY ./compose/production/django/celery/beat/start.sh /start-celerybeat.sh
|
||||
RUN sed -i 's/\r//' /start-celerybeat.sh
|
||||
RUN chmod +x /start-celerybeat.sh
|
||||
COPY ./compose/production/django/start /start
|
||||
RUN sed -i 's/\r//' /start
|
||||
RUN chmod +x /start
|
||||
RUN chown django /start
|
||||
{% if cookiecutter.use_celery == "y" %}
|
||||
COPY ./compose/production/django/celery/worker/start /start-celeryworker
|
||||
RUN sed -i 's/\r//' /start-celeryworker
|
||||
RUN chmod +x /start-celeryworker
|
||||
RUN chown django /start-celeryworker
|
||||
|
||||
COPY ./compose/production/django/celery/beat/start /start-celerybeat
|
||||
RUN sed -i 's/\r//' /start-celerybeat
|
||||
RUN chmod +x /start-celerybeat
|
||||
RUN chown django /start-celerybeat
|
||||
{% endif %}
|
||||
COPY . /app
|
||||
|
||||
RUN chown -R django /app
|
||||
|
@ -36,4 +47,4 @@ USER django
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
ENTRYPOINT ["/entrypoint"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
# N.B. If only .env files supported variable expansion...
|
||||
export CELERY_BROKER_URL="${REDIS_URL}"
|
||||
|
||||
if [ -z "${POSTGRES_USER}" ]; then
|
||||
base_postgres_image_default_user='postgres'
|
||||
export POSTGRES_USER="${base_postgres_image_default_user}"
|
||||
fi
|
||||
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
|
||||
|
||||
postgres_ready() {
|
||||
python << END
|
||||
import sys
|
||||
|
||||
import psycopg2
|
||||
|
||||
try:
|
||||
psycopg2.connect(
|
||||
dbname="${POSTGRES_DB}",
|
||||
user="${POSTGRES_USER}",
|
||||
password="${POSTGRES_PASSWORD}",
|
||||
host="${POSTGRES_HOST}",
|
||||
port="${POSTGRES_PORT}",
|
||||
)
|
||||
except psycopg2.OperationalError:
|
||||
sys.exit(-1)
|
||||
sys.exit(0)
|
||||
|
||||
END
|
||||
}
|
||||
until postgres_ready; do
|
||||
>&2 echo 'Waiting for PostgreSQL to become available...'
|
||||
sleep 1
|
||||
done
|
||||
>&2 echo 'PostgreSQL is available'
|
||||
|
||||
exec "$@"
|
|
@ -1,46 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
# todo: turn on after #1295
|
||||
# set -o nounset
|
||||
|
||||
|
||||
cmd="$@"
|
||||
|
||||
# This entrypoint is used to play nicely with the current cookiecutter configuration.
|
||||
# Since docker-compose relies heavily on environment variables itself for configuration, we'd have to define multiple
|
||||
# environment variables just to support cookiecutter out of the box. That makes no sense, so this little entrypoint
|
||||
# does all this for us.
|
||||
export REDIS_URL=redis://redis:6379
|
||||
|
||||
# the official postgres image uses 'postgres' as default user if not set explictly.
|
||||
if [ -z "$POSTGRES_USER" ]; then
|
||||
export POSTGRES_USER=postgres
|
||||
fi
|
||||
|
||||
export DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_USER
|
||||
{% if cookiecutter.use_celery == 'y' %}
|
||||
export CELERY_BROKER_URL=$REDIS_URL/0
|
||||
{% endif %}
|
||||
|
||||
function postgres_ready(){
|
||||
python << END
|
||||
import sys
|
||||
import psycopg2
|
||||
try:
|
||||
conn = psycopg2.connect(dbname="$POSTGRES_USER", user="$POSTGRES_USER", password="$POSTGRES_PASSWORD", host="postgres")
|
||||
except psycopg2.OperationalError:
|
||||
sys.exit(-1)
|
||||
sys.exit(0)
|
||||
END
|
||||
}
|
||||
|
||||
until postgres_ready; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - continuing..."
|
||||
exec $cmd
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
@ -6,4 +6,4 @@ set -o nounset
|
|||
|
||||
|
||||
python /app/manage.py collectstatic --noinput
|
||||
/usr/local/bin/gunicorn config.wsgi -w 4 -b 0.0.0.0:5000 --chdir=/app
|
||||
/usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app
|
|
@ -1,10 +1,6 @@
|
|||
FROM postgres:{{ cookiecutter.postgresql_version }}
|
||||
|
||||
COPY ./compose/production/postgres/backup.sh /usr/local/bin/backup
|
||||
RUN chmod +x /usr/local/bin/backup
|
||||
|
||||
COPY ./compose/production/postgres/restore.sh /usr/local/bin/restore
|
||||
RUN chmod +x /usr/local/bin/restore
|
||||
|
||||
COPY ./compose/production/postgres/list-backups.sh /usr/local/bin/list-backups
|
||||
RUN chmod +x /usr/local/bin/list-backups
|
||||
COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
|
||||
RUN chmod +x /usr/local/bin/maintenance/*
|
||||
RUN mv /usr/local/bin/maintenance/* /usr/local/bin \
|
||||
&& rmdir /usr/local/bin/maintenance
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
# we might run into trouble when using the default `postgres` user, e.g. when dropping the postgres
|
||||
# database in restore.sh. Check that something else is used here
|
||||
if [ "$POSTGRES_USER" == "postgres" ]
|
||||
then
|
||||
echo "creating a backup as the postgres user is not supported, make sure to set the POSTGRES_USER environment variable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# export the postgres password so that subsequent commands don't ask for it
|
||||
export PGPASSWORD=$POSTGRES_PASSWORD
|
||||
|
||||
echo "creating backup"
|
||||
echo "---------------"
|
||||
|
||||
FILENAME=backup_$(date +'%Y_%m_%dT%H_%M_%S').sql.gz
|
||||
pg_dump -h postgres -U $POSTGRES_USER | gzip > /backups/$FILENAME
|
||||
|
||||
echo "successfully created backup $FILENAME"
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
echo "listing available backups"
|
||||
echo "-------------------------"
|
||||
ls /backups/
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
BACKUP_DIR_PATH='/backups'
|
||||
BACKUP_FILE_PREFIX='backup'
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
countdown() {
|
||||
declare desc="A simple countdown. Source: https://superuser.com/a/611582"
|
||||
local seconds="${1}"
|
||||
local d=$(($(date +%s) + "${seconds}"))
|
||||
while [ "$d" -ge `date +%s` ]; do
|
||||
echo -ne "$(date -u --date @$(($d - `date +%s`)) +%H:%M:%S)\r";
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
message_newline() {
|
||||
echo
|
||||
}
|
||||
|
||||
message_debug()
|
||||
{
|
||||
echo -e "DEBUG: ${@}"
|
||||
}
|
||||
|
||||
message_welcome()
|
||||
{
|
||||
echo -e "\e[1m${@}\e[0m"
|
||||
}
|
||||
|
||||
message_warning()
|
||||
{
|
||||
echo -e "\e[33mWARNING\e[0m: ${@}"
|
||||
}
|
||||
|
||||
message_error()
|
||||
{
|
||||
echo -e "\e[31mERROR\e[0m: ${@}"
|
||||
}
|
||||
|
||||
message_info()
|
||||
{
|
||||
echo -e "\e[37mINFO\e[0m: ${@}"
|
||||
}
|
||||
|
||||
message_suggestion()
|
||||
{
|
||||
echo -e "\e[33mSUGGESTION\e[0m: ${@}"
|
||||
}
|
||||
|
||||
message_success()
|
||||
{
|
||||
echo -e "\e[32mSUCCESS\e[0m: ${@}"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
yes_no() {
|
||||
declare desc="Prompt for confirmation. \$\"\{1\}\": confirmation message."
|
||||
local arg1="${1}"
|
||||
|
||||
local response=
|
||||
read -r -p "${arg1} (y/[n])? " response
|
||||
if [[ "${response}" =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
### Create a database backup.
|
||||
###
|
||||
### Usage:
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres backup
|
||||
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
working_dir="$(dirname ${0})"
|
||||
source "${working_dir}/_sourced/constants.sh"
|
||||
source "${working_dir}/_sourced/messages.sh"
|
||||
|
||||
|
||||
message_welcome "Backing up the '${POSTGRES_DB}' database..."
|
||||
|
||||
|
||||
if [[ "${POSTGRES_USER}" == "postgres" ]]; then
|
||||
message_error "Backing up as 'postgres' user is not supported. Assign 'POSTGRES_USER' env with another one and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PGHOST="${POSTGRES_HOST}"
|
||||
export PGPORT="${POSTGRES_PORT}"
|
||||
export PGUSER="${POSTGRES_USER}"
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
export PGDATABASE="${POSTGRES_DB}"
|
||||
|
||||
backup_filename="${BACKUP_FILE_PREFIX}_$(date +'%Y_%m_%dT%H_%M_%S').sql.gz"
|
||||
pg_dump | gzip > "${BACKUP_DIR_PATH}/${backup_filename}"
|
||||
|
||||
|
||||
message_success "'${POSTGRES_DB}' database backup '${backup_filename}' has been created and placed in '${BACKUP_DIR_PATH}'."
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
### View backups.
|
||||
###
|
||||
### Usage:
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres backups
|
||||
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
working_dir="$(dirname ${0})"
|
||||
source "${working_dir}/_sourced/constants.sh"
|
||||
source "${working_dir}/_sourced/messages.sh"
|
||||
|
||||
|
||||
message_welcome "These are the backups you have got:"
|
||||
|
||||
ls -lht "${BACKUP_DIR_PATH}"
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
### Restore database from a backup.
|
||||
###
|
||||
### Parameters:
|
||||
### <1> filename of an existing backup.
|
||||
###
|
||||
### Usage:
|
||||
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres restore <1>
|
||||
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
working_dir="$(dirname ${0})"
|
||||
source "${working_dir}/_sourced/constants.sh"
|
||||
source "${working_dir}/_sourced/messages.sh"
|
||||
|
||||
|
||||
if [[ -z ${1+x} ]]; then
|
||||
message_error "Backup filename is not specified yet it is a required parameter. Make sure you provide one and try again."
|
||||
exit 1
|
||||
fi
|
||||
backup_filename="${BACKUP_DIR_PATH}/${1}"
|
||||
if [[ ! -f "${backup_filename}" ]]; then
|
||||
message_error "No backup with the specified filename found. Check out the 'backups' maintenance script output to see if there is one and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
message_welcome "Restoring the '${POSTGRES_DB}' database from the '${backup_filename}' backup..."
|
||||
|
||||
if [[ "${POSTGRES_USER}" == "postgres" ]]; then
|
||||
message_error "Restoring as 'postgres' user is not supported. Assign 'POSTGRES_USER' env with another one and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PGHOST="${POSTGRES_HOST}"
|
||||
export PGPORT="${POSTGRES_PORT}"
|
||||
export PGUSER="${POSTGRES_USER}"
|
||||
export PGPASSWORD="${POSTGRES_PASSWORD}"
|
||||
export PGDATABASE="${POSTGRES_DB}"
|
||||
|
||||
message_info "Dropping the database..."
|
||||
dropdb "${PGDATABASE}"
|
||||
|
||||
message_info "Creating a new database..."
|
||||
createdb --owner="${POSTGRES_USER}"
|
||||
|
||||
message_info "Applying the backup to the new database..."
|
||||
gunzip -c "${backup_filename}" | psql "${POSTGRES_DB}"
|
||||
|
||||
message_success "The '${POSTGRES_DB}' database has been restored from the '${backup_filename}' backup."
|
|
@ -1,58 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
|
||||
# we might run into trouble when using the default `postgres` user, e.g. when dropping the postgres
|
||||
# database in restore.sh. Check that something else is used here
|
||||
if [ "$POSTGRES_USER" == "postgres" ]
|
||||
then
|
||||
echo "restoring as the postgres user is not supported, make sure to set the POSTGRES_USER environment variable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# export the postgres password so that subsequent commands don't ask for it
|
||||
export PGPASSWORD=$POSTGRES_PASSWORD
|
||||
|
||||
# check that we have an argument for a filename candidate
|
||||
if [[ $# -eq 0 ]] ; then
|
||||
echo 'usage:'
|
||||
echo ' docker-compose -f production.yml run postgres restore <backup-file>'
|
||||
echo ''
|
||||
echo 'to get a list of available backups, run:'
|
||||
echo ' docker-compose -f production.yml run postgres list-backups'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set the backupfile variable
|
||||
BACKUPFILE=/backups/$1
|
||||
|
||||
# check that the file exists
|
||||
if ! [ -f $BACKUPFILE ]; then
|
||||
echo "backup file not found"
|
||||
echo 'to get a list of available backups, run:'
|
||||
echo ' docker-compose -f production.yml run postgres list-backups'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "beginning restore from $1"
|
||||
echo "-------------------------"
|
||||
|
||||
# delete the db
|
||||
# deleting the db can fail. Spit out a comment if this happens but continue since the db
|
||||
# is created in the next step
|
||||
echo "deleting old database $POSTGRES_USER"
|
||||
if dropdb -h postgres -U $POSTGRES_USER $POSTGRES_USER
|
||||
then echo "deleted $POSTGRES_USER database"
|
||||
else echo "database $POSTGRES_USER does not exist, continue"
|
||||
fi
|
||||
|
||||
# create a new database
|
||||
echo "creating new database $POSTGRES_USER"
|
||||
createdb -h postgres -U $POSTGRES_USER $POSTGRES_USER -O $POSTGRES_USER
|
||||
|
||||
# restore the database
|
||||
echo "restoring database $POSTGRES_USER"
|
||||
gunzip -c $BACKUPFILE | psql -h postgres -U $POSTGRES_USER
|
|
@ -1,232 +1,119 @@
|
|||
"""
|
||||
Base settings for {{cookiecutter.project_name}} project.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/dev/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/dev/ref/settings/
|
||||
Base settings to build other settings files upon.
|
||||
"""
|
||||
|
||||
import environ
|
||||
|
||||
ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/)
|
||||
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
|
||||
|
||||
# Load operating system environment variables and then prepare to use them
|
||||
env = environ.Env()
|
||||
|
||||
# .env file, should load only in development environment
|
||||
READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=False)
|
||||
|
||||
if READ_DOT_ENV_FILE:
|
||||
# Operating System Environment variables have precedence over variables defined in the .env file,
|
||||
# that is to say variables from the .env files will only be used if not defined
|
||||
# as environment variables.
|
||||
env_file = str(ROOT_DIR.path('.env'))
|
||||
print('Loading : {}'.format(env_file))
|
||||
env.read_env(env_file)
|
||||
print('The .env file has been loaded. See base.py for more information')
|
||||
# OS environment variables take precedence over variables from .env
|
||||
env.read_env(str(ROOT_DIR.path('.env')))
|
||||
|
||||
# APP CONFIGURATION
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||
DEBUG = env.bool('DJANGO_DEBUG', False)
|
||||
# Local time zone. Choices are
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# though not all of them may be available with every OS.
|
||||
# In Windows, this must be set to your system time zone.
|
||||
TIME_ZONE = '{{ cookiecutter.timezone }}'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
|
||||
SITE_ID = 1
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
||||
USE_I18N = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
|
||||
USE_L10N = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
|
||||
USE_TZ = True
|
||||
|
||||
# DATABASES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||
{% if cookiecutter.use_docker == 'y' -%}
|
||||
DATABASES = {
|
||||
'default': env.db('DATABASE_URL'),
|
||||
}
|
||||
{%- else %}
|
||||
DATABASES = {
|
||||
'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'),
|
||||
}
|
||||
{%- endif %}
|
||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||
|
||||
# URLS
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
||||
# APPS
|
||||
# ------------------------------------------------------------------------------
|
||||
DJANGO_APPS = [
|
||||
# Default Django apps:
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
# Useful template tags:
|
||||
# 'django.contrib.humanize',
|
||||
|
||||
# Admin
|
||||
# 'django.contrib.humanize', # Handy template tags
|
||||
'django.contrib.admin',
|
||||
]
|
||||
THIRD_PARTY_APPS = [
|
||||
'crispy_forms', # Form layouts
|
||||
'allauth', # registration
|
||||
'allauth.account', # registration
|
||||
'allauth.socialaccount', # registration
|
||||
'crispy_forms',
|
||||
'allauth',
|
||||
'allauth.account',
|
||||
'allauth.socialaccount',
|
||||
'rest_framework',
|
||||
]
|
||||
|
||||
# Apps specific for this project go here.
|
||||
LOCAL_APPS = [
|
||||
# custom users app
|
||||
'{{ cookiecutter.project_slug }}.users.apps.UsersConfig',
|
||||
'{{ cookiecutter.project_slug }}.users.apps.UsersAppConfig',
|
||||
# Your stuff: custom apps go here
|
||||
]
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||
|
||||
# MIDDLEWARE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
# MIGRATIONS CONFIGURATION
|
||||
# MIGRATIONS
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
|
||||
MIGRATION_MODULES = {
|
||||
'sites': '{{ cookiecutter.project_slug }}.contrib.sites.migrations'
|
||||
}
|
||||
|
||||
# DEBUG
|
||||
# AUTHENTICATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||
DEBUG = env.bool('DJANGO_DEBUG', False)
|
||||
|
||||
# FIXTURE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
|
||||
FIXTURE_DIRS = (
|
||||
str(APPS_DIR.path('fixtures')),
|
||||
)
|
||||
|
||||
# EMAIL CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
|
||||
|
||||
# MANAGER CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
||||
ADMINS = [
|
||||
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'allauth.account.auth_backends.AuthenticationBackend',
|
||||
]
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
|
||||
AUTH_USER_MODEL = 'users.User'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
|
||||
LOGIN_REDIRECT_URL = 'users:redirect'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
|
||||
LOGIN_URL = 'account_login'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
||||
MANAGERS = ADMINS
|
||||
|
||||
# DATABASE CONFIGURATION
|
||||
# PASSWORDS
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
|
||||
# Uses django-environ to accept uri format
|
||||
# See: https://django-environ.readthedocs.io/en/latest/#supported-types
|
||||
DATABASES = {
|
||||
'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.project_slug}}'),
|
||||
}
|
||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||
|
||||
|
||||
# GENERAL CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# In a Windows environment this must be set to your system time zone.
|
||||
TIME_ZONE = '{{ cookiecutter.timezone }}'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
|
||||
SITE_ID = 1
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
||||
USE_I18N = True
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
|
||||
USE_L10N = True
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
|
||||
USE_TZ = True
|
||||
|
||||
# TEMPLATE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||
TEMPLATES = [
|
||||
{
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
||||
'DIRS': [
|
||||
str(APPS_DIR.path('templates')),
|
||||
],
|
||||
'OPTIONS': {
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
||||
'debug': DEBUG,
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
|
||||
'loaders': [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
],
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.template.context_processors.i18n',
|
||||
'django.template.context_processors.media',
|
||||
'django.template.context_processors.static',
|
||||
'django.template.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
# Your stuff: custom template context processors go here
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
# See: http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||
|
||||
# STATIC FILE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
||||
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
|
||||
STATICFILES_DIRS = [
|
||||
str(APPS_DIR.path('static')),
|
||||
]
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
|
||||
STATICFILES_FINDERS = [
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
]
|
||||
|
||||
# MEDIA CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
|
||||
MEDIA_ROOT = str(APPS_DIR('media'))
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# URL Configuration
|
||||
# ------------------------------------------------------------------------------
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
||||
# PASSWORD STORAGE SETTINGS
|
||||
# ------------------------------------------------------------------------------
|
||||
# See https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
|
||||
PASSWORD_HASHERS = [
|
||||
# https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
|
||||
'django.contrib.auth.hashers.Argon2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
||||
]
|
||||
|
||||
# PASSWORD VALIDATION
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
|
@ -242,50 +129,142 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
},
|
||||
]
|
||||
|
||||
# AUTHENTICATION CONFIGURATION
|
||||
# MIDDLEWARE
|
||||
# ------------------------------------------------------------------------------
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
'allauth.account.auth_backends.AuthenticationBackend',
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
# Some really nice defaults
|
||||
ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
||||
ACCOUNT_EMAIL_REQUIRED = True
|
||||
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||
# STATIC
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
||||
STATIC_ROOT = str(ROOT_DIR('staticfiles'))
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#static-url
|
||||
STATIC_URL = '/static/'
|
||||
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
|
||||
STATICFILES_DIRS = [
|
||||
str(APPS_DIR.path('static')),
|
||||
]
|
||||
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
|
||||
STATICFILES_FINDERS = [
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
]
|
||||
|
||||
ACCOUNT_ALLOW_REGISTRATION = env.bool('DJANGO_ACCOUNT_ALLOW_REGISTRATION', True)
|
||||
ACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.AccountAdapter'
|
||||
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter'
|
||||
# MEDIA
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
|
||||
MEDIA_ROOT = str(APPS_DIR('media'))
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# Custom user app defaults
|
||||
# Select the correct user model
|
||||
AUTH_USER_MODEL = 'users.User'
|
||||
LOGIN_REDIRECT_URL = 'users:redirect'
|
||||
LOGIN_URL = 'account_login'
|
||||
# TEMPLATES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||
TEMPLATES = [
|
||||
{
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
||||
'DIRS': [
|
||||
str(APPS_DIR.path('templates')),
|
||||
],
|
||||
'OPTIONS': {
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
|
||||
'debug': DEBUG,
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
|
||||
'loaders': [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
],
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.template.context_processors.i18n',
|
||||
'django.template.context_processors.media',
|
||||
'django.template.context_processors.static',
|
||||
'django.template.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||
|
||||
# SLUGLIFIER
|
||||
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
||||
{% if cookiecutter.use_celery == 'y' %}
|
||||
########## CELERY
|
||||
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryConfig']
|
||||
# FIXTURES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
|
||||
FIXTURE_DIRS = (
|
||||
str(APPS_DIR.path('fixtures')),
|
||||
)
|
||||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
|
||||
|
||||
# ADMIN
|
||||
# ------------------------------------------------------------------------------
|
||||
# Django Admin URL.
|
||||
ADMIN_URL = 'admin/'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
|
||||
ADMINS = [
|
||||
("""{{cookiecutter.author_name}}""", '{{cookiecutter.email}}'),
|
||||
]
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
|
||||
MANAGERS = ADMINS
|
||||
|
||||
{% if cookiecutter.use_celery == 'y' -%}
|
||||
# Celery
|
||||
# ------------------------------------------------------------------------------
|
||||
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryAppConfig']
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url
|
||||
CELERY_BROKER_URL = env('CELERY_BROKER_URL', default='django://')
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
|
||||
if CELERY_BROKER_URL == 'django://':
|
||||
CELERY_RESULT_BACKEND = 'redis://'
|
||||
else:
|
||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
||||
########## END CELERY
|
||||
{% endif %}
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
|
||||
CELERY_ACCEPT_CONTENT = ['json']
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
|
||||
{%- if cookiecutter.use_compressor == 'y'-%}
|
||||
{%- endif %}
|
||||
# django-allauth
|
||||
# ------------------------------------------------------------------------------
|
||||
ACCOUNT_ALLOW_REGISTRATION = env.bool('DJANGO_ACCOUNT_ALLOW_REGISTRATION', True)
|
||||
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||
ACCOUNT_AUTHENTICATION_METHOD = 'username'
|
||||
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||
ACCOUNT_EMAIL_REQUIRED = True
|
||||
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||
ACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.AccountAdapter'
|
||||
# https://django-allauth.readthedocs.io/en/latest/configuration.html
|
||||
SOCIALACCOUNT_ADAPTER = '{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter'
|
||||
|
||||
{% if cookiecutter.use_compressor == 'y' -%}
|
||||
# django-compressor
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://django-compressor.readthedocs.io/en/latest/quickstart/#installation
|
||||
INSTALLED_APPS += ['compressor']
|
||||
STATICFILES_FINDERS += ['compressor.finders.CompressorFinder']
|
||||
|
||||
{%- endif %}
|
||||
|
||||
# Location of root django.contrib.admin URL, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
||||
ADMIN_URL = r'^admin/'
|
||||
|
||||
# Your common stuff: Below this line define 3rd party library settings
|
||||
# Your stuff...
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,47 +1,22 @@
|
|||
"""
|
||||
Local settings for {{cookiecutter.project_name}} project.
|
||||
|
||||
- Run in Debug mode
|
||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %}
|
||||
- Use mailhog for emails via Docker
|
||||
{% elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
||||
- Use mailhog for emails
|
||||
{% else %}
|
||||
- Use console backend for emails
|
||||
{% endif %}
|
||||
- Add Django Debug Toolbar
|
||||
- Add django-extensions as app
|
||||
"""
|
||||
|
||||
from .base import * # noqa
|
||||
from .base import env
|
||||
|
||||
# DEBUG
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
DEBUG = env.bool('DJANGO_DEBUG', default=True)
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
# Note: This key only used for development and testing.
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||
DEBUG = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = [
|
||||
"localhost",
|
||||
"0.0.0.0",
|
||||
"127.0.0.1",
|
||||
]
|
||||
|
||||
# Mail settings
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
EMAIL_PORT = 1025
|
||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' %}
|
||||
EMAIL_HOST = env('EMAIL_HOST', default='mailhog')
|
||||
{% elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %}
|
||||
EMAIL_HOST = 'localhost'
|
||||
{% else %}
|
||||
EMAIL_HOST = 'localhost'
|
||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND',
|
||||
default='django.core.mail.backends.console.EmailBackend')
|
||||
{% endif %}
|
||||
|
||||
# CACHING
|
||||
# CACHES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
|
@ -49,40 +24,62 @@ CACHES = {
|
|||
}
|
||||
}
|
||||
|
||||
# TEMPLATES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG # noqa F405
|
||||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' -%}
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||
EMAIL_HOST = env('EMAIL_HOST', default='mailhog')
|
||||
{%- elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%}
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||
EMAIL_HOST = 'localhost'
|
||||
{%- else -%}
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend')
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||
EMAIL_HOST = 'localhost'
|
||||
{%- endif %}
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
||||
EMAIL_PORT = 1025
|
||||
|
||||
# django-debug-toolbar
|
||||
# ------------------------------------------------------------------------------
|
||||
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
|
||||
INSTALLED_APPS += ['debug_toolbar', ]
|
||||
|
||||
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2', ]
|
||||
{% if cookiecutter.use_docker == 'y' %}
|
||||
{# [cookiecutter-django] This is a workaround to flake8 "imported but unused" errors #}
|
||||
import socket
|
||||
import os
|
||||
# tricks to have debug toolbar when developing with docker
|
||||
if os.environ.get('USE_DOCKER') == 'yes':
|
||||
ip = socket.gethostbyname(socket.gethostname())
|
||||
INTERNAL_IPS += [ip[:-1] + '1']
|
||||
{% endif %}
|
||||
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
|
||||
INSTALLED_APPS += ['debug_toolbar'] # noqa F405
|
||||
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware
|
||||
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] # noqa F405
|
||||
# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'DISABLE_PANELS': [
|
||||
'debug_toolbar.panels.redirects.RedirectsPanel',
|
||||
],
|
||||
'SHOW_TEMPLATE_CONTEXT': True,
|
||||
}
|
||||
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
|
||||
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2']
|
||||
{% if cookiecutter.use_docker == 'y' -%}
|
||||
if env('USE_DOCKER') == 'yes':
|
||||
import socket
|
||||
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
|
||||
INTERNAL_IPS += [ip[:-1] + '1' for ip in ips]
|
||||
{%- endif %}
|
||||
|
||||
# django-extensions
|
||||
# ------------------------------------------------------------------------------
|
||||
INSTALLED_APPS += ['django_extensions', ]
|
||||
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
|
||||
INSTALLED_APPS += ['django_extensions'] # noqa F405
|
||||
{% if cookiecutter.use_celery == 'y' -%}
|
||||
|
||||
# TESTING
|
||||
# Celery
|
||||
# ------------------------------------------------------------------------------
|
||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||
{% if cookiecutter.use_celery == 'y' %}
|
||||
########## CELERY
|
||||
# In development, all tasks will be executed locally by blocking until the task returns
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_always_eager
|
||||
CELERY_TASK_ALWAYS_EAGER = True
|
||||
########## END CELERY
|
||||
{% endif %}
|
||||
# Your local stuff: Below this line define 3rd party library settings
|
||||
CELERY_EAGER_PROPAGATES = True
|
||||
|
||||
{%- endif %}
|
||||
# Your stuff...
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,211 +1,200 @@
|
|||
"""
|
||||
Production settings for {{cookiecutter.project_name}} project.
|
||||
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
- Use WhiteNoise for serving static files{% endif %}
|
||||
- Use Amazon's S3 for storing {% if cookiecutter.use_whitenoise == 'n' -%}static files and {% endif %}uploaded media
|
||||
- Use mailgun to send emails
|
||||
- Use Redis for cache
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
- Use sentry for error logging
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_opbeat == 'y' %}
|
||||
- Use opbeat for error reporting
|
||||
{% endif %}
|
||||
"""
|
||||
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
import logging
|
||||
{% endif %}
|
||||
|
||||
{% endif -%}
|
||||
from .base import * # noqa
|
||||
from .base import env
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
# Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY')
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{ cookiecutter.domain_name }}'])
|
||||
|
||||
|
||||
# This ensures that Django will be able to detect a secure connection
|
||||
# properly on Heroku.
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
|
||||
{%- if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
# raven sentry client
|
||||
# See https://docs.sentry.io/clients/python/integrations/django/
|
||||
INSTALLED_APPS += ['raven.contrib.django.raven_compat', ]
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_whitenoise == 'y' %}
|
||||
# Use Whitenoise to serve static files
|
||||
# See: https://whitenoise.readthedocs.io/
|
||||
WHITENOISE_MIDDLEWARE = ['whitenoise.middleware.WhiteNoiseMiddleware', ]
|
||||
MIDDLEWARE = WHITENOISE_MIDDLEWARE + MIDDLEWARE
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
RAVEN_MIDDLEWARE = ['raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware']
|
||||
MIDDLEWARE = RAVEN_MIDDLEWARE + MIDDLEWARE
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_opbeat == 'y' -%}
|
||||
# opbeat integration
|
||||
# See https://opbeat.com/languages/django/
|
||||
INSTALLED_APPS += ['opbeat.contrib.django', ]
|
||||
OPBEAT = {
|
||||
'ORGANIZATION_ID': env('DJANGO_OPBEAT_ORGANIZATION_ID'),
|
||||
'APP_ID': env('DJANGO_OPBEAT_APP_ID'),
|
||||
'SECRET_TOKEN': env('DJANGO_OPBEAT_SECRET_TOKEN')
|
||||
}
|
||||
MIDDLEWARE = ['opbeat.contrib.django.middleware.OpbeatAPMMiddleware', ] + MIDDLEWARE
|
||||
{% endif %}
|
||||
|
||||
# SECURITY CONFIGURATION
|
||||
# DATABASES
|
||||
# ------------------------------------------------------------------------------
|
||||
# See https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.security
|
||||
# and https://docs.djangoproject.com/en/dev/howto/deployment/checklist/#run-manage-py-check-deploy
|
||||
DATABASES['default'] = env.db('DATABASE_URL') # noqa F405
|
||||
DATABASES['default']['ATOMIC_REQUESTS'] = True # noqa F405
|
||||
DATABASES['default']['CONN_MAX_AGE'] = env.int('CONN_MAX_AGE', default=60) # noqa F405
|
||||
|
||||
# set this to 60 seconds and then to 518400 when you can prove it works
|
||||
SECURE_HSTS_SECONDS = 60
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
|
||||
'DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS', default=True)
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
|
||||
'DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True)
|
||||
SECURE_BROWSER_XSS_FILTER = True
|
||||
SESSION_COOKIE_SECURE = True
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True)
|
||||
CSRF_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_HTTPONLY = True
|
||||
X_FRAME_OPTIONS = 'DENY'
|
||||
|
||||
# SITE CONFIGURATION
|
||||
# CACHES
|
||||
# ------------------------------------------------------------------------------
|
||||
# Hosts/domain names that are valid for this site
|
||||
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['{{cookiecutter.domain_name}}', ])
|
||||
# END SITE CONFIGURATION
|
||||
|
||||
INSTALLED_APPS += ['gunicorn', ]
|
||||
|
||||
|
||||
# STORAGE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# Uploaded Media Files
|
||||
# ------------------------
|
||||
# See: http://django-storages.readthedocs.io/en/latest/index.html
|
||||
INSTALLED_APPS += ['storages', ]
|
||||
|
||||
AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID')
|
||||
AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY')
|
||||
AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME')
|
||||
AWS_AUTO_CREATE_BUCKET = True
|
||||
AWS_QUERYSTRING_AUTH = False
|
||||
|
||||
# AWS cache settings, don't change unless you know what you're doing:
|
||||
AWS_EXPIRY = 60 * 60 * 24 * 7
|
||||
|
||||
# TODO See: https://github.com/jschneier/django-storages/issues/47
|
||||
# Revert the following and use str after the above-mentioned bug is fixed in
|
||||
# either django-storage-redux or boto
|
||||
control = 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIRY, AWS_EXPIRY)
|
||||
AWS_HEADERS = {
|
||||
'Cache-Control': bytes(control, encoding='latin-1')
|
||||
}
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT, used for managing
|
||||
# stored files.
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
|
||||
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||
{% else %}
|
||||
# See:http://stackoverflow.com/questions/10390244/
|
||||
from storages.backends.s3boto3 import S3Boto3Storage
|
||||
StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static') # noqa
|
||||
MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media', file_overwrite=False) # noqa
|
||||
DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage'
|
||||
|
||||
MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME
|
||||
{%- endif %}
|
||||
|
||||
# Static Assets
|
||||
# ------------------------
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
{% else %}
|
||||
STATIC_URL = 'https://s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
|
||||
STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage'
|
||||
# See: https://github.com/antonagestam/collectfast
|
||||
# For Django 1.7+, 'collectfast' should come before
|
||||
# 'django.contrib.staticfiles'
|
||||
AWS_PRELOAD_METADATA = True
|
||||
INSTALLED_APPS = ['collectfast', ] + INSTALLED_APPS
|
||||
{%- endif %}
|
||||
{% if cookiecutter.use_compressor == 'y'-%}
|
||||
# COMPRESSOR
|
||||
# ------------------------------------------------------------------------------
|
||||
COMPRESS_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||
COMPRESS_URL = STATIC_URL
|
||||
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
||||
{%- endif %}
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
|
||||
default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>')
|
||||
EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}]')
|
||||
SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
|
||||
|
||||
# Anymail with Mailgun
|
||||
INSTALLED_APPS += ['anymail', ]
|
||||
ANYMAIL = {
|
||||
'MAILGUN_API_KEY': env('DJANGO_MAILGUN_API_KEY'),
|
||||
'MAILGUN_SENDER_DOMAIN': env('MAILGUN_SENDER_DOMAIN')
|
||||
}
|
||||
EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend'
|
||||
|
||||
# TEMPLATE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.cached.Loader
|
||||
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||
('django.template.loaders.cached.Loader', [
|
||||
'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ]),
|
||||
]
|
||||
{% set _DEFAULT_CONN_MAX_AGE=60 %}
|
||||
# DATABASE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Use the Heroku-style specification
|
||||
# Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ
|
||||
DATABASES['default'] = env.db('DATABASE_URL')
|
||||
DATABASES['default']['CONN_MAX_AGE'] = env.int('CONN_MAX_AGE', default={{ _DEFAULT_CONN_MAX_AGE }})
|
||||
|
||||
|
||||
# CACHING
|
||||
# ------------------------------------------------------------------------------
|
||||
REDIS_LOCATION = '{0}/{1}'.format(env('REDIS_URL', default='redis://127.0.0.1:6379'), 0)
|
||||
|
||||
# Heroku URL does not pass the DB number, so we parse it in
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
'LOCATION': REDIS_LOCATION,
|
||||
'LOCATION': env('REDIS_URL'),
|
||||
'OPTIONS': {
|
||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||
'IGNORE_EXCEPTIONS': True, # mimics memcache behavior.
|
||||
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
||||
# Mimicing memcache behavior.
|
||||
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
|
||||
'IGNORE_EXCEPTIONS': True,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
# Sentry Configuration
|
||||
SENTRY_DSN = env('DJANGO_SENTRY_DSN')
|
||||
# SECURITY
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
|
||||
SECURE_SSL_REDIRECT = env.bool('DJANGO_SECURE_SSL_REDIRECT', default=True)
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
|
||||
SESSION_COOKIE_SECURE = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
|
||||
CSRF_COOKIE_SECURE = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
|
||||
CSRF_COOKIE_HTTPONLY = True
|
||||
# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
|
||||
# TODO: set this to 60 seconds first and then to 518400 once you prove the former works
|
||||
SECURE_HSTS_SECONDS = 60
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool('DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS', default=True)
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
|
||||
SECURE_HSTS_PRELOAD = env.bool('DJANGO_SECURE_HSTS_PRELOAD', default=True)
|
||||
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = env.bool('DJANGO_SECURE_CONTENT_TYPE_NOSNIFF', default=True)
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
|
||||
SECURE_BROWSER_XSS_FILTER = True
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
|
||||
X_FRAME_OPTIONS = 'DENY'
|
||||
|
||||
# STORAGES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://django-storages.readthedocs.io/en/latest/#installation
|
||||
INSTALLED_APPS += ['storages'] # noqa F405
|
||||
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||
AWS_ACCESS_KEY_ID = env('DJANGO_AWS_ACCESS_KEY_ID')
|
||||
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||
AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY')
|
||||
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||
AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME')
|
||||
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||
AWS_AUTO_CREATE_BUCKET = True
|
||||
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||
AWS_QUERYSTRING_AUTH = False
|
||||
# DO NOT change these unless you know what you're doing.
|
||||
_AWS_EXPIRY = 60 * 60 * 24 * 7
|
||||
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
|
||||
AWS_S3_OBJECT_PARAMETERS = {
|
||||
'CacheControl': f'max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate',
|
||||
}
|
||||
|
||||
# STATIC
|
||||
# ------------------------
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
{%- else %}
|
||||
STATICFILES_STORAGE = 'config.settings.production.StaticRootS3BotoStorage'
|
||||
STATIC_URL = f'https://s3.amazonaws.com/{AWS_STORAGE_BUCKET_NAME}/static/'
|
||||
{%- endif %}
|
||||
|
||||
# MEDIA
|
||||
# ------------------------------------------------------------------------------
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||
MEDIA_URL = f'https://s3.amazonaws.com/{AWS_STORAGE_BUCKET_NAME}/'
|
||||
{%- else %}
|
||||
# region http://stackoverflow.com/questions/10390244/
|
||||
from storages.backends.s3boto3 import S3Boto3Storage # noqa E402
|
||||
StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static') # noqa
|
||||
MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media', file_overwrite=False) # noqa
|
||||
# endregion
|
||||
DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage'
|
||||
MEDIA_URL = f'https://s3.amazonaws.com/{AWS_STORAGE_BUCKET_NAME}/media/'
|
||||
{%- endif %}
|
||||
|
||||
# TEMPLATES
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||
TEMPLATES[0]['OPTIONS']['loaders'] = [ # noqa F405
|
||||
(
|
||||
'django.template.loaders.cached.Loader',
|
||||
[
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
]
|
||||
),
|
||||
]
|
||||
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
|
||||
DEFAULT_FROM_EMAIL = env(
|
||||
'DJANGO_DEFAULT_FROM_EMAIL',
|
||||
default='{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>'
|
||||
)
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email
|
||||
SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
|
||||
EMAIL_SUBJECT_PREFIX = env('DJANGO_EMAIL_SUBJECT_PREFIX', default='[{{cookiecutter.project_name}}]')
|
||||
|
||||
# ADMIN
|
||||
# ------------------------------------------------------------------------------
|
||||
# Django Admin URL regex.
|
||||
ADMIN_URL = env('DJANGO_ADMIN_URL')
|
||||
|
||||
# Anymail (Mailgun)
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
|
||||
INSTALLED_APPS += ['anymail'] # noqa F405
|
||||
EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend'
|
||||
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
|
||||
ANYMAIL = {
|
||||
'MAILGUN_API_KEY': env('MAILGUN_API_KEY'),
|
||||
'MAILGUN_SENDER_DOMAIN': env('MAILGUN_DOMAIN')
|
||||
}
|
||||
|
||||
# Gunicorn
|
||||
# ------------------------------------------------------------------------------
|
||||
INSTALLED_APPS += ['gunicorn'] # noqa F405
|
||||
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
# WhiteNoise
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://whitenoise.evans.io/en/latest/django.html#enable-whitenoise
|
||||
MIDDLEWARE = ['whitenoise.middleware.WhiteNoiseMiddleware'] + MIDDLEWARE # noqa F405
|
||||
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_compressor == 'y' -%}
|
||||
# django-compressor
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
|
||||
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
||||
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
|
||||
COMPRESS_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
|
||||
COMPRESS_URL = STATIC_URL
|
||||
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_whitenoise == 'n' -%}
|
||||
# Collectfast
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://github.com/antonagestam/collectfast#installation
|
||||
INSTALLED_APPS = ['collectfast'] + INSTALLED_APPS # noqa F405
|
||||
AWS_PRELOAD_METADATA = True
|
||||
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_sentry == 'y' -%}
|
||||
# raven
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.sentry.io/clients/python/integrations/django/
|
||||
INSTALLED_APPS += ['raven.contrib.django.raven_compat'] # noqa F405
|
||||
MIDDLEWARE = ['raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware'] + MIDDLEWARE
|
||||
|
||||
# Sentry
|
||||
# ------------------------------------------------------------------------------
|
||||
SENTRY_DSN = env('SENTRY_DSN')
|
||||
SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient')
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'root': {
|
||||
'level': 'WARNING',
|
||||
'handlers': ['sentry', ],
|
||||
'handlers': ['sentry'],
|
||||
},
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
|
@ -227,33 +216,34 @@ LOGGING = {
|
|||
'loggers': {
|
||||
'django.db.backends': {
|
||||
'level': 'ERROR',
|
||||
'handlers': ['console', ],
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
},
|
||||
'raven': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', ],
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
},
|
||||
'sentry.errors': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', ],
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
},
|
||||
'django.security.DisallowedHost': {
|
||||
'level': 'ERROR',
|
||||
'handlers': ['console', 'sentry', ],
|
||||
'handlers': ['console', 'sentry'],
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
SENTRY_CELERY_LOGLEVEL = env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO)
|
||||
RAVEN_CONFIG = {
|
||||
'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO),
|
||||
'DSN': SENTRY_DSN
|
||||
'dsn': SENTRY_DSN
|
||||
}
|
||||
{% elif cookiecutter.use_sentry_for_error_reporting == 'n' %}
|
||||
# LOGGING CONFIGURATION
|
||||
|
||||
{%- else %}
|
||||
# LOGGING
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
||||
# A sample logging configuration. The only tangible logging
|
||||
|
@ -278,7 +268,7 @@ LOGGING = {
|
|||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false', ],
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
},
|
||||
'console': {
|
||||
|
@ -289,20 +279,18 @@ LOGGING = {
|
|||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['mail_admins', ],
|
||||
'handlers': ['mail_admins'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True
|
||||
},
|
||||
'django.security.DisallowedHost': {
|
||||
'level': 'ERROR',
|
||||
'handlers': ['console', 'mail_admins', ],
|
||||
'handlers': ['console', 'mail_admins'],
|
||||
'propagate': True
|
||||
}
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
# Custom Admin URL, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
||||
ADMIN_URL = env('DJANGO_ADMIN_URL')
|
||||
|
||||
# Your production stuff: Below this line define 3rd party library settings
|
||||
{% endif %}
|
||||
# Your stuff...
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,61 +1,55 @@
|
|||
"""
|
||||
Test settings for {{cookiecutter.project_name}} project.
|
||||
|
||||
- Used to run tests fast on the continuous integration server and locally
|
||||
With these settings, tests run faster.
|
||||
"""
|
||||
|
||||
from .base import * # noqa
|
||||
from .base import env
|
||||
|
||||
|
||||
# DEBUG
|
||||
# GENERAL
|
||||
# ------------------------------------------------------------------------------
|
||||
# Turn debug off so tests run faster
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
|
||||
DEBUG = False
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = False
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
SECRET_KEY = env("DJANGO_SECRET_KEY", default="!!!SET DJANGO_SECRET_KEY!!!")
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
|
||||
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
||||
|
||||
# SECRET CONFIGURATION
|
||||
# CACHES
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
|
||||
# Note: This key only used for development and testing.
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
|
||||
|
||||
# Mail settings
|
||||
# ------------------------------------------------------------------------------
|
||||
EMAIL_HOST = 'localhost'
|
||||
EMAIL_PORT = 1025
|
||||
|
||||
# In-memory email backend stores messages in django.core.mail.outbox
|
||||
# for unit testing purposes
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
||||
|
||||
# CACHING
|
||||
# ------------------------------------------------------------------------------
|
||||
# Speed advantages of in-memory caching without having to run Memcached
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': ''
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": ""
|
||||
}
|
||||
}
|
||||
|
||||
# TESTING
|
||||
# PASSWORDS
|
||||
# ------------------------------------------------------------------------------
|
||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
|
||||
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
||||
|
||||
|
||||
# PASSWORD HASHING
|
||||
# TEMPLATES
|
||||
# ------------------------------------------------------------------------------
|
||||
# Use fast password hasher so tests run faster
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
|
||||
TEMPLATES[0]["OPTIONS"]["debug"] = DEBUG # noqa F405
|
||||
TEMPLATES[0]["OPTIONS"]["loaders"] = [ # noqa F405
|
||||
(
|
||||
"django.template.loaders.cached.Loader",
|
||||
[
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
],
|
||||
)
|
||||
]
|
||||
|
||||
# TEMPLATE LOADERS
|
||||
# EMAIL
|
||||
# ------------------------------------------------------------------------------
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
|
||||
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
|
||||
EMAIL_HOST = "localhost"
|
||||
# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
|
||||
EMAIL_PORT = 1025
|
||||
|
||||
# Your stuff...
|
||||
# ------------------------------------------------------------------------------
|
||||
# Keep templates in memory so tests run faster
|
||||
TEMPLATES[0]['OPTIONS']['loaders'] = [
|
||||
['django.template.loaders.cached.Loader', [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
], ],
|
||||
]
|
||||
|
|
|
@ -1,37 +1,52 @@
|
|||
from django.conf import settings
|
||||
from django.conf.urls import include, url
|
||||
from django.urls import include, path
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.views.generic import TemplateView
|
||||
from django.views import defaults as default_views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name='home'),
|
||||
url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name='about'),
|
||||
|
||||
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
||||
path(
|
||||
"about/",
|
||||
TemplateView.as_view(template_name="pages/about.html"),
|
||||
name="about",
|
||||
),
|
||||
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
|
||||
url(settings.ADMIN_URL, admin.site.urls),
|
||||
|
||||
path(settings.ADMIN_URL, admin.site.urls),
|
||||
# User management
|
||||
url(r'^users/', include('{{ cookiecutter.project_slug }}.users.urls', namespace='users')),
|
||||
url(r'^accounts/', include('allauth.urls')),
|
||||
|
||||
path(
|
||||
"users/",
|
||||
include("{{ cookiecutter.project_slug }}.users.urls", namespace="users"),
|
||||
),
|
||||
path("accounts/", include("allauth.urls")),
|
||||
# Your stuff: custom urls includes go here
|
||||
|
||||
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
] + static(
|
||||
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
# This allows the error pages to be debugged during development, just visit
|
||||
# these url in browser to see how these error pages look like.
|
||||
urlpatterns += [
|
||||
url(r'^400/$', default_views.bad_request, kwargs={'exception': Exception('Bad Request!')}),
|
||||
url(r'^403/$', default_views.permission_denied, kwargs={'exception': Exception('Permission Denied')}),
|
||||
url(r'^404/$', default_views.page_not_found, kwargs={'exception': Exception('Page not Found')}),
|
||||
url(r'^500/$', default_views.server_error),
|
||||
path(
|
||||
"400/",
|
||||
default_views.bad_request,
|
||||
kwargs={"exception": Exception("Bad Request!")},
|
||||
),
|
||||
path(
|
||||
"403/",
|
||||
default_views.permission_denied,
|
||||
kwargs={"exception": Exception("Permission Denied")},
|
||||
),
|
||||
path(
|
||||
"404/",
|
||||
default_views.page_not_found,
|
||||
kwargs={"exception": Exception("Page not Found")},
|
||||
),
|
||||
path("500/", default_views.server_error),
|
||||
]
|
||||
if 'debug_toolbar' in settings.INSTALLED_APPS:
|
||||
if "debug_toolbar" in settings.INSTALLED_APPS:
|
||||
import debug_toolbar
|
||||
urlpatterns = [
|
||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
|
||||
urlpatterns = [path("__debug__/", include(debug_toolbar.urls))] + urlpatterns
|
||||
|
|
|
@ -23,12 +23,10 @@ from django.core.wsgi import get_wsgi_application
|
|||
app_path = os.path.abspath(os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), os.pardir))
|
||||
sys.path.append(os.path.join(app_path, '{{ cookiecutter.project_slug }}'))
|
||||
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
|
||||
{%- endif %}
|
||||
|
||||
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
|
||||
# if running multiple sites in the same mod_wsgi process. To fix this, use
|
||||
# mod_wsgi daemon mode with each site in its own daemon process, or use
|
||||
|
@ -39,7 +37,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
|
|||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
application = get_wsgi_application()
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
application = Sentry(application)
|
||||
{%- endif %}
|
||||
|
|
|
@ -27,19 +27,19 @@ import sys
|
|||
extensions = []
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = '{{ cookiecutter.project_name }}'
|
||||
project = "{{ cookiecutter.project_name }}"
|
||||
copyright = """{% now 'utc', '%Y' %}, {{ cookiecutter.author_name }}"""
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
|
@ -47,9 +47,9 @@ copyright = """{% now 'utc', '%Y' %}, {{ cookiecutter.author_name }}"""
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.1'
|
||||
version = "0.1"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.1'
|
||||
release = "0.1"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -63,7 +63,7 @@ release = '0.1'
|
|||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
# default_role = None
|
||||
|
@ -80,7 +80,7 @@ exclude_patterns = ['_build']
|
|||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
@ -90,7 +90,7 @@ pygments_style = 'sphinx'
|
|||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
|
@ -119,7 +119,7 @@ html_theme = 'default'
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
html_static_path = ["_static"]
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
|
@ -163,7 +163,7 @@ html_static_path = ['_static']
|
|||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = '{{ cookiecutter.project_slug }}doc'
|
||||
htmlhelp_basename = "{{ cookiecutter.project_slug }}doc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
@ -171,10 +171,8 @@ htmlhelp_basename = '{{ cookiecutter.project_slug }}doc'
|
|||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
# 'preamble': '',
|
||||
}
|
||||
|
@ -182,10 +180,13 @@ latex_elements = {
|
|||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index',
|
||||
'{{ cookiecutter.project_slug }}.tex',
|
||||
'{{ cookiecutter.project_name }} Documentation',
|
||||
"""{{ cookiecutter.author_name }}""", 'manual'),
|
||||
(
|
||||
"index",
|
||||
"{{ cookiecutter.project_slug }}.tex",
|
||||
"{{ cookiecutter.project_name }} Documentation",
|
||||
"""{{ cookiecutter.author_name }}""",
|
||||
"manual",
|
||||
)
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -214,8 +215,13 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', '{{ cookiecutter.project_slug }}', '{{ cookiecutter.project_name }} Documentation',
|
||||
["""{{ cookiecutter.author_name }}"""], 1)
|
||||
(
|
||||
"index",
|
||||
"{{ cookiecutter.project_slug }}",
|
||||
"{{ cookiecutter.project_name }} Documentation",
|
||||
["""{{ cookiecutter.author_name }}"""],
|
||||
1,
|
||||
)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -228,9 +234,15 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', '{{ cookiecutter.project_slug }}', '{{ cookiecutter.project_name }} Documentation',
|
||||
"""{{ cookiecutter.author_name }}""", '{{ cookiecutter.project_name }}',
|
||||
"""{{ cookiecutter.description }}""", 'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"{{ cookiecutter.project_slug }}",
|
||||
"{{ cookiecutter.project_name }} Documentation",
|
||||
"""{{ cookiecutter.author_name }}""",
|
||||
"{{ cookiecutter.project_name }}",
|
||||
"""{{ cookiecutter.description }}""",
|
||||
"Miscellaneous",
|
||||
)
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
|
||||
# PostgreSQL
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!!
|
||||
POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
CONN_MAX_AGE=
|
||||
|
||||
# Domain name, used by caddy
|
||||
DOMAIN_NAME={{ cookiecutter.domain_name }}
|
||||
|
||||
# General settings
|
||||
# DJANGO_READ_DOT_ENV_FILE=True
|
||||
DJANGO_ADMIN_URL=
|
||||
DJANGO_SETTINGS_MODULE=config.settings.production
|
||||
DJANGO_SECRET_KEY=!!!SET DJANGO_SECRET_KEY!!!
|
||||
DJANGO_ALLOWED_HOSTS=.{{ cookiecutter.domain_name }}
|
||||
|
||||
# AWS Settings
|
||||
DJANGO_AWS_ACCESS_KEY_ID=
|
||||
DJANGO_AWS_SECRET_ACCESS_KEY=
|
||||
DJANGO_AWS_STORAGE_BUCKET_NAME=
|
||||
|
||||
# Used with email
|
||||
DJANGO_MAILGUN_API_KEY=
|
||||
DJANGO_SERVER_EMAIL=
|
||||
MAILGUN_SENDER_DOMAIN=
|
||||
|
||||
# Security! Better to use DNS for this task, but you can use redirect
|
||||
DJANGO_SECURE_SSL_REDIRECT=False
|
||||
|
||||
# django-allauth
|
||||
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
# Sentry
|
||||
DJANGO_SENTRY_DSN=
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_opbeat == 'y' -%}
|
||||
DJANGO_OPBEAT_ORGANIZATION_ID=
|
||||
DJANGO_OPBEAT_APP_ID=
|
||||
DJANGO_OPBEAT_SECRET_TOKEN=
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_compressor == 'y' -%}
|
||||
COMPRESS_ENABLED=
|
||||
{% endif %}
|
|
@ -9,54 +9,66 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: ./compose/local/django/Dockerfile
|
||||
image: {{ cookiecutter.project_slug }}_local_django
|
||||
depends_on:
|
||||
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog{% endif %}
|
||||
- postgres
|
||||
{%- if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog
|
||||
{%- endif %}
|
||||
volumes:
|
||||
- .:/app
|
||||
environment:
|
||||
- POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
- USE_DOCKER=yes
|
||||
env_file:
|
||||
- ./.envs/.local/.django
|
||||
- ./.envs/.local/.postgres
|
||||
ports:
|
||||
- "8000:8000"
|
||||
command: /start.sh
|
||||
command: /start
|
||||
|
||||
postgres:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./compose/production/postgres/Dockerfile
|
||||
image: {{ cookiecutter.project_slug }}_production_postgres
|
||||
volumes:
|
||||
- postgres_data_local:/var/lib/postgresql/data
|
||||
- postgres_backup_local:/backups
|
||||
environment:
|
||||
- POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
{% if cookiecutter.use_mailhog == 'y' %}
|
||||
env_file:
|
||||
- ./.envs/.local/.postgres
|
||||
{%- if cookiecutter.use_mailhog == 'y' %}
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog:v1.0.0
|
||||
ports:
|
||||
- "8025:8025"
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_celery == 'y' %}
|
||||
|
||||
{%- endif %}
|
||||
{%- if cookiecutter.use_celery == 'y' %}
|
||||
|
||||
redis:
|
||||
image: redis:3.0
|
||||
image: redis:3.2
|
||||
|
||||
celeryworker:
|
||||
# https://github.com/docker/compose/issues/3220
|
||||
<<: *django
|
||||
image: {{ cookiecutter.project_slug }}_local_celeryworker
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog{% endif %}
|
||||
- postgres
|
||||
{% if cookiecutter.use_mailhog == 'y' -%}
|
||||
- mailhog
|
||||
{%- endif %}
|
||||
ports: []
|
||||
command: /start-celeryworker.sh
|
||||
command: /start-celeryworker
|
||||
|
||||
celerybeat:
|
||||
# https://github.com/docker/compose/issues/3220
|
||||
<<: *django
|
||||
image: {{ cookiecutter.project_slug }}_local_celerybeat
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres{% if cookiecutter.use_mailhog == 'y' %}
|
||||
- mailhog{% endif %}
|
||||
- postgres
|
||||
{% if cookiecutter.use_mailhog == 'y' -%}
|
||||
- mailhog
|
||||
{%- endif %}
|
||||
ports: []
|
||||
command: /start-celerybeat.sh
|
||||
{% endif %}
|
||||
command: /start-celerybeat
|
||||
|
||||
{%- endif %}
|
||||
|
|
6
{{cookiecutter.project_slug}}/locale/README.rst
Normal file
6
{{cookiecutter.project_slug}}/locale/README.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
Translations
|
||||
============
|
||||
|
||||
Translations will be placed in this folder when running::
|
||||
|
||||
python manage.py makemessages
|
|
@ -2,8 +2,8 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
||||
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
|
@ -19,11 +19,12 @@ if __name__ == '__main__':
|
|||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
)
|
||||
|
||||
raise
|
||||
|
||||
# This allows easy placement of apps within the interior
|
||||
# {{ cookiecutter.project_slug }} directory.
|
||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.join(current_path, '{{ cookiecutter.project_slug }}'))
|
||||
sys.path.append(os.path.join(current_path, "{{ cookiecutter.project_slug }}"))
|
||||
|
||||
execute_from_command_line(sys.argv)
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
import os
|
||||
from typing import Sequence
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT_DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
PRODUCTION_DOTENVS_DIR_PATH = os.path.join(ROOT_DIR_PATH, ".envs", ".production")
|
||||
PRODUCTION_DOTENV_FILE_PATHS = [
|
||||
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".django"),
|
||||
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".postgres"),
|
||||
os.path.join(PRODUCTION_DOTENVS_DIR_PATH, ".caddy"),
|
||||
]
|
||||
DOTENV_FILE_PATH = os.path.join(ROOT_DIR_PATH, ".env")
|
||||
|
||||
|
||||
def merge(
|
||||
output_file_path: str, merged_file_paths: Sequence[str], append_linesep: bool = True
|
||||
) -> None:
|
||||
with open(output_file_path, "w") as output_file:
|
||||
for merged_file_path in merged_file_paths:
|
||||
with open(merged_file_path, "r") as merged_file:
|
||||
merged_file_content = merged_file.read()
|
||||
output_file.write(merged_file_content)
|
||||
if append_linesep:
|
||||
output_file.write(os.linesep)
|
||||
|
||||
|
||||
def main():
|
||||
merge(DOTENV_FILE_PATH, PRODUCTION_DOTENV_FILE_PATHS)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("merged_file_count", range(3))
|
||||
@pytest.mark.parametrize("append_linesep", [True, False])
|
||||
def test_merge(tmpdir_factory, merged_file_count: int, append_linesep: bool):
|
||||
tmp_dir_path = str(tmpdir_factory.getbasetemp())
|
||||
|
||||
output_file_path = os.path.join(tmp_dir_path, ".env")
|
||||
|
||||
expected_output_file_content = ""
|
||||
merged_file_paths = []
|
||||
for i in range(merged_file_count):
|
||||
merged_file_ord = i + 1
|
||||
|
||||
merged_filename = ".service{}".format(merged_file_ord)
|
||||
merged_file_path = os.path.join(tmp_dir_path, merged_filename)
|
||||
|
||||
merged_file_content = merged_filename * merged_file_ord
|
||||
|
||||
with open(merged_file_path, "w+") as file:
|
||||
file.write(merged_file_content)
|
||||
|
||||
expected_output_file_content += merged_file_content
|
||||
if append_linesep:
|
||||
expected_output_file_content += os.linesep
|
||||
|
||||
merged_file_paths.append(merged_file_path)
|
||||
|
||||
merge(output_file_path, merged_file_paths, append_linesep)
|
||||
|
||||
with open(output_file_path, "r") as output_file:
|
||||
actual_output_file_content = output_file.read()
|
||||
|
||||
assert actual_output_file_content == expected_output_file_content
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -3,54 +3,38 @@
|
|||
"version": "{{ cookiecutter.version }}",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
{% if cookiecutter.js_task_runner == 'Grunt' %}
|
||||
"autoprefixer-core": "~5.2.1",
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
"bootstrap": "^4.0.0",
|
||||
{% endif %}
|
||||
"connect-livereload": "~0.3.2",
|
||||
"cssnano": "~2.1.0",
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-bg-shell": "~2.3.1",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-postcss": "~0.5.5",
|
||||
"grunt-sass": "~1.0.0",
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
"jquery": "^3.2.1-slim",
|
||||
{% endif %}
|
||||
"load-grunt-tasks": "~3.2.0",
|
||||
"pixrem": "~1.3.1",
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
"popper.js": "^1.12.3",
|
||||
{% endif %}
|
||||
"time-grunt": "~1.2.1"
|
||||
{% elif cookiecutter.js_task_runner == 'Gulp' %}
|
||||
{% if cookiecutter.js_task_runner == 'Gulp' %}
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
"bootstrap": "^4.0.0",
|
||||
{% endif %}
|
||||
"browser-sync": "^2.14.0",
|
||||
"del": "^2.2.2",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-autoprefixer": "^3.1.1",
|
||||
"gulp-autoprefixer": "^5.0.0",
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
"gulp-concat": "^2.6.1",
|
||||
{% endif %}
|
||||
"gulp-cssnano": "^2.1.2",
|
||||
"gulp-imagemin": "^3.0.3",
|
||||
"gulp-imagemin": "^4.1.0",
|
||||
"gulp-pixrem": "^1.0.0",
|
||||
"gulp-plumber": "^1.1.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-sass": "^2.3.2",
|
||||
"gulp-uglify": "^2.0.0",
|
||||
"gulp-sass": "^3.1.0",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"gulp-util": "^3.0.7",
|
||||
{% if cookiecutter.custom_bootstrap_compilation == 'y' %}
|
||||
"jquery": "^3.2.1-slim",
|
||||
"popper.js": "^1.12.3",
|
||||
{% endif %}
|
||||
"run-sequence": "^1.2.2"
|
||||
"run-sequence": "^2.1.1"
|
||||
{% endif %}
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
{% if cookiecutter.js_task_runner == 'Gulp' %}
|
||||
"dev": "gulp"
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,48 +10,53 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: ./compose/production/django/Dockerfile
|
||||
image: {{ cookiecutter.project_slug }}_production_django
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
env_file: .env
|
||||
command: /gunicorn.sh
|
||||
env_file:
|
||||
- ./.envs/.production/.django
|
||||
- ./.envs/.production/.postgres
|
||||
command: /start
|
||||
|
||||
postgres:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./compose/production/postgres/Dockerfile
|
||||
image: {{ cookiecutter.project_slug }}_production_postgres
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- postgres_backup:/backups
|
||||
env_file: .env
|
||||
env_file:
|
||||
- ./.envs/.production/.postgres
|
||||
|
||||
caddy:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./compose/production/caddy/Dockerfile
|
||||
image: {{ cookiecutter.project_slug }}_production_caddy
|
||||
depends_on:
|
||||
- django
|
||||
volumes:
|
||||
- caddy:/root/.caddy
|
||||
env_file: .env
|
||||
env_file:
|
||||
- ./.envs/.production/.caddy
|
||||
ports:
|
||||
- "0.0.0.0:80:80"
|
||||
- "0.0.0.0:443:443"
|
||||
|
||||
redis:
|
||||
image: redis:3.0
|
||||
{% if cookiecutter.use_celery == 'y' %}
|
||||
image: redis:3.2
|
||||
{%- if cookiecutter.use_celery == 'y' %}
|
||||
|
||||
celeryworker:
|
||||
<<: *django
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
command: /start-celeryworker.sh
|
||||
image: {{ cookiecutter.project_slug }}_production_celeryworker
|
||||
command: /start-celeryworker
|
||||
|
||||
celerybeat:
|
||||
<<: *django
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
command: /start-celerybeat.sh
|
||||
{% endif %}
|
||||
image: {{ cookiecutter.project_slug }}_production_celerybeat
|
||||
command: /start-celerybeat
|
||||
|
||||
{%- endif %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[pytest]
|
||||
DJANGO_SETTINGS_MODULE=config.settings.test
|
||||
{% if cookiecutter.js_task_runner != 'None' %}
|
||||
{%- if cookiecutter.js_task_runner != 'None' %}
|
||||
norecursedirs = node_modules
|
||||
{% endif %}
|
||||
{%- endif %}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# This file is here because many Platforms as a Service look for
|
||||
# requirements.txt in the root directory of a project.
|
||||
# This file is expected by Heroku.
|
||||
|
||||
-r requirements/production.txt
|
||||
|
|
|
@ -1,61 +1,30 @@
|
|||
# Wheel 0.25+ needed to install certain packages on CPython 3.5+
|
||||
# like Pillow and psycopg2
|
||||
# See http://bitly.com/wheel-building-fails-CPython-35
|
||||
# Verified bug on Python 3.5.1
|
||||
wheel==0.30.0
|
||||
|
||||
|
||||
# Conservative Django
|
||||
django==1.11.10 # pyup: <2.0
|
||||
|
||||
# Configuration
|
||||
django-environ==0.4.4
|
||||
{% if cookiecutter.use_whitenoise == 'y' -%}
|
||||
whitenoise==3.3.1
|
||||
pytz==2018.4 # https://github.com/stub42/pytz
|
||||
python-slugify==1.2.5 # https://github.com/un33k/python-slugify
|
||||
Pillow==5.1.0 # https://github.com/python-pillow/Pillow
|
||||
{%- if cookiecutter.use_compressor == "y" %}
|
||||
rcssmin==1.0.6{% if cookiecutter.windows == 'y' %} --install-option="--without-c-extensions"{% endif %} # https://github.com/ndparker/rcssmin
|
||||
{%- endif %}
|
||||
argon2-cffi==18.1.0 # https://github.com/hynek/argon2_cffi
|
||||
{%- if cookiecutter.use_whitenoise == 'y' %}
|
||||
whitenoise==3.3.1 # https://github.com/evansd/whitenoise
|
||||
{%- endif %}
|
||||
redis>=2.10.5 # https://github.com/antirez/redis
|
||||
{%- if cookiecutter.use_celery == "y" %}
|
||||
celery==4.2.0 # pyup: <5.0 # https://github.com/celery/celery
|
||||
{%- endif %}
|
||||
|
||||
|
||||
# Forms
|
||||
django-crispy-forms==1.7.0
|
||||
|
||||
# Models
|
||||
django-model-utils==3.1.1
|
||||
|
||||
# Images
|
||||
Pillow==5.0.0
|
||||
|
||||
# Password storage
|
||||
argon2-cffi==18.1.0
|
||||
|
||||
# For user registration, either via email or social
|
||||
# Well-built with regular release cycles!
|
||||
django-allauth==0.35.0
|
||||
|
||||
{% if cookiecutter.windows == 'y' -%}
|
||||
# On Windows, you must download/install psycopg2 manually
|
||||
# from http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg
|
||||
{% else %}
|
||||
# Python-PostgreSQL Database Adapter
|
||||
psycopg2==2.7.4
|
||||
# Django
|
||||
# ------------------------------------------------------------------------------
|
||||
django==2.0.6 # pyup: < 2.1 # https://www.djangoproject.com/
|
||||
django-environ==0.4.4 # https://github.com/joke2k/django-environ
|
||||
django-model-utils==3.1.2 # https://github.com/jazzband/django-model-utils
|
||||
django-allauth==0.36.0 # https://github.com/pennersr/django-allauth
|
||||
django-crispy-forms==1.7.2 # https://github.com/django-crispy-forms/django-crispy-forms
|
||||
{%- if cookiecutter.use_compressor == "y" %}
|
||||
django-compressor==2.2 # https://github.com/django-compressor/django-compressor
|
||||
{%- endif %}
|
||||
django-redis==4.9.0 # https://github.com/niwinz/django-redis
|
||||
|
||||
# Unicode slugification
|
||||
awesome-slugify==1.6.5
|
||||
|
||||
# Time zones support
|
||||
pytz==2018.3
|
||||
|
||||
# Redis support
|
||||
django-redis==4.8.0
|
||||
redis>=2.10.5
|
||||
|
||||
{% if cookiecutter.use_celery == "y" %}
|
||||
celery==4.1.0 # pyup: <5.0
|
||||
{% endif %}
|
||||
|
||||
{% if cookiecutter.use_compressor == "y" %}
|
||||
rcssmin==1.0.6 {% if cookiecutter.windows == 'y' %}--install-option="--without-c-extensions"{% endif %}
|
||||
django-compressor==2.2
|
||||
{% endif %}
|
||||
|
||||
# Your custom requirements go here
|
||||
# Django REST Framework
|
||||
djangorestframework==3.8.2 # https://github.com/encode/django-rest-framework
|
||||
coreapi==2.3.3 # https://github.com/core-api/python-client
|
|
@ -1,19 +1,30 @@
|
|||
# Local development dependencies go here
|
||||
-r base.txt
|
||||
-r ./base.txt
|
||||
|
||||
coverage==4.5.1
|
||||
django-coverage-plugin==1.5.0
|
||||
Werkzeug==0.14.1 # https://github.com/pallets/werkzeug
|
||||
ipdb==0.11 # https://github.com/gotcha/ipdb
|
||||
Sphinx==1.7.5 # https://github.com/sphinx-doc/sphinx
|
||||
{%- if cookiecutter.use_docker == 'y' %}
|
||||
psycopg2==2.7.4 --no-binary psycopg2 # https://github.com/psycopg/psycopg2
|
||||
{%- else %}
|
||||
psycopg2-binary==2.7.4 # https://github.com/psycopg/psycopg2
|
||||
{%- endif %}
|
||||
|
||||
Sphinx==1.7.0
|
||||
django-extensions==1.9.9
|
||||
Werkzeug==0.14.1
|
||||
django-test-plus==1.0.22
|
||||
factory-boy==2.10.0
|
||||
# Testing
|
||||
# ------------------------------------------------------------------------------
|
||||
pytest==3.6.1 # https://github.com/pytest-dev/pytest
|
||||
pytest-sugar==0.9.1 # https://github.com/Frozenball/pytest-sugar
|
||||
|
||||
django-debug-toolbar==1.9.1
|
||||
# Code quality
|
||||
# ------------------------------------------------------------------------------
|
||||
flake8==3.5.0 # https://github.com/PyCQA/flake8
|
||||
coverage==4.5.1 # https://github.com/nedbat/coveragepy
|
||||
|
||||
# improved REPL
|
||||
ipdb==0.10.3
|
||||
# Django
|
||||
# ------------------------------------------------------------------------------
|
||||
factory-boy==2.11.1 # https://github.com/FactoryBoy/factory_boy
|
||||
django-test-plus==1.0.22 # https://github.com/revsys/django-test-plus
|
||||
|
||||
pytest-django==3.1.2
|
||||
pytest-sugar==0.9.1
|
||||
django-debug-toolbar==1.9.1 # https://github.com/jazzband/django-debug-toolbar
|
||||
django-extensions==2.0.7 # https://github.com/django-extensions/django-extensions
|
||||
django-coverage-plugin==1.5.0 # https://github.com/nedbat/django_coverage_plugin
|
||||
pytest-django==3.2.1 # https://github.com/pytest-dev/pytest-django
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user