diff --git a/README.md b/README.md
index a9bf1990f..b73ecef9e 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[](https://github.com/ambv/black)
[](https://pyup.io/repos/github/cookiecutter/cookiecutter-django/)
-[](https://discord.gg/uFXweDQc5a)
+[](https://discord.gg/rAWFUP47d2)
[](https://www.codetriage.com/cookiecutter/cookiecutter-django)
Powered by [Cookiecutter](https://github.com/cookiecutter/cookiecutter), Cookiecutter Django is a framework for jumpstarting
@@ -20,7 +20,7 @@ production-ready Django projects quickly.
## Features
- For Django 4.2
-- Works with Python 3.11
+- Works with Python 3.12
- Renders Django projects with 100% starting test coverage
- Twitter [Bootstrap](https://github.com/twbs/bootstrap) v5
- [12-Factor](https://12factor.net) based settings via [django-environ](https://github.com/joke2k/django-environ)
@@ -51,7 +51,7 @@ _These features can be enabled during initial project setup._
## Constraints
- Only maintained 3rd party libraries are used.
-- Uses PostgreSQL everywhere: 10 - 15 ([MySQL fork](https://github.com/mabdullahadeel/cookiecutter-django-mysql) also available).
+- Uses PostgreSQL everywhere: 12 - 16 ([MySQL fork](https://github.com/mabdullahadeel/cookiecutter-django-mysql) also available).
- Environment variables for configuration (This won't work with Apache/mod_wsgi).
## Support this Project!
@@ -65,19 +65,15 @@ This project is an open source project run by volunteers. You can sponsor us via
Projects that provide financial support to the maintainers:
----
+### Two Scoops of Django
-
-
-
+[](https://www.feldroy.com/two-scoops-press#two-scoops-of-django)
Two Scoops of Django 3.x is the best ice cream-themed Django reference in the universe!
### PyUp
-
-
-
+[](https://pyup.io)
PyUp brings you automated security and dependency updates used by Google and other organizations. Free for open source projects!
@@ -133,12 +129,11 @@ Answer the prompts with your own desired [options](http://cookiecutter-django.re
Choose from 1, 2, 3 [1]: 1
use_docker [n]: n
Select postgresql_version:
- 1 - 15
- 2 - 14
- 3 - 13
- 4 - 12
- 5 - 11
- 6 - 10
+ 1 - 16
+ 2 - 15
+ 3 - 14
+ 4 - 13
+ 5 - 12
Choose from 1, 2, 3, 4, 5 [1]: 1
Select cloud_provider:
1 - AWS
@@ -152,7 +147,7 @@ Answer the prompts with your own desired [options](http://cookiecutter-django.re
4 - Mandrill
5 - Postmark
6 - Sendgrid
- 7 - SendinBlue
+ 7 - Brevo (formerly SendinBlue)
8 - SparkPost
9 - Other SMTP
Choose from 1, 2, 3, 4, 5, 6, 7, 8, 9 [1]: 1
diff --git a/cookiecutter.json b/cookiecutter.json
index e343617d1..86e44f368 100644
--- a/cookiecutter.json
+++ b/cookiecutter.json
@@ -18,7 +18,7 @@
"windows": "n",
"editor": ["None", "PyCharm", "VS Code"],
"use_docker": "n",
- "postgresql_version": ["15", "14", "13", "12", "11", "10"],
+ "postgresql_version": ["16", "15", "14", "13", "12"],
"cloud_provider": ["AWS", "GCP", "Azure", "None"],
"mail_service": [
"Mailgun",
@@ -27,7 +27,7 @@
"Mandrill",
"Postmark",
"Sendgrid",
- "SendinBlue",
+ "Brevo",
"SparkPost",
"Other SMTP"
],
diff --git a/docs/deployment-on-heroku.rst b/docs/deployment-on-heroku.rst
index 71c6e11b2..fdd953e09 100644
--- a/docs/deployment-on-heroku.rst
+++ b/docs/deployment-on-heroku.rst
@@ -46,7 +46,7 @@ Run these commands to deploy the project to Heroku:
# Assign with AWS_STORAGE_BUCKET_NAME
heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME=
- git push heroku master
+ git push heroku main
heroku run python manage.py createsuperuser
diff --git a/docs/deployment-on-pythonanywhere.rst b/docs/deployment-on-pythonanywhere.rst
index 2fa6a960c..726f325e2 100644
--- a/docs/deployment-on-pythonanywhere.rst
+++ b/docs/deployment-on-pythonanywhere.rst
@@ -37,7 +37,7 @@ Make sure your project is fully committed and pushed up to Bitbucket or Github o
mkvirtualenv --python=/usr/bin/python3.10 my-project-name
pip install -r requirements/production.txt # may take a few minutes
-.. note:: We're creating the virtualenv using Python 3.10 (``--python=/usr/bin/python3.10```), although Cookiecutter Django generates a project for Python 3.11. This is because, at time of writing, PythonAnywhere only supports Python 3.10. It shouldn't be a problem, but if is, you may try changing the Python version to 3.11 and see if it works. If it does, please let us know, or even better, submit a pull request to update this section.
+.. note:: We're creating the virtualenv using Python 3.10 (``--python=/usr/bin/python3.10```), although Cookiecutter Django generates a project for Python 3.12. This is because, at time of writing, PythonAnywhere only supports Python 3.10. It shouldn't be a problem, but if is, you may try changing the Python version to 3.12 and see if it works. If it does, please let us know, or even better, submit a pull request to update this section.
Setting environment variables in the console
--------------------------------------------
diff --git a/docs/deployment-with-docker.rst b/docs/deployment-with-docker.rst
index 3d2f9f813..ebc42a52d 100644
--- a/docs/deployment-with-docker.rst
+++ b/docs/deployment-with-docker.rst
@@ -14,7 +14,7 @@ Prerequisites
Understanding the Docker Compose Setup
--------------------------------------
-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:
+Before you begin, check out the ``docker-compose.production.yml`` file in the root of this project. Keep note of how it provides configuration for the following services:
* ``django``: your application running behind ``Gunicorn``;
* ``postgres``: PostgreSQL database with the application's relational data;
@@ -107,7 +107,7 @@ To solve this, you can either:
2. create a ``.env`` file in the root of the project with just variables you need. You'll need to also define them in ``.envs/.production/.django`` (hence duplicating them).
3. set these variables when running the build command::
- DJANGO_AWS_S3_CUSTOM_DOMAIN=example.com docker compose -f production.yml build``.
+ DJANGO_AWS_S3_CUSTOM_DOMAIN=example.com docker compose -f docker-compose.production.yml build``.
None of these options are ideal, we're open to suggestions on how to improve this. If you think you have one, please open an issue or a pull request.
@@ -122,42 +122,42 @@ Building & Running Production Stack
You will need to build the stack first. To do that, run::
- docker compose -f production.yml build
+ docker compose -f docker-compose.production.yml build
Once this is ready, you can run it with::
- docker compose -f production.yml up
+ docker compose -f docker-compose.production.yml up
To run the stack and detach the containers, run::
- docker compose -f production.yml up -d
+ docker compose -f docker-compose.production.yml up -d
To run a migration, open up a second terminal and run::
- docker compose -f production.yml run --rm django python manage.py migrate
+ docker compose -f docker-compose.production.yml run --rm django python manage.py migrate
To create a superuser, run::
- docker compose -f production.yml run --rm django python manage.py createsuperuser
+ docker compose -f docker-compose.production.yml run --rm django python manage.py createsuperuser
If you need a shell, run::
- docker compose -f production.yml run --rm django python manage.py shell
+ docker compose -f docker-compose.production.yml run --rm django python manage.py shell
To check the logs out, run::
- docker compose -f production.yml logs
+ docker compose -f docker-compose.production.yml logs
If you want to scale your application, run::
- docker compose -f production.yml up --scale django=4
- docker compose -f production.yml up --scale celeryworker=2
+ docker compose -f docker-compose.production.yml up --scale django=4
+ docker compose -f docker-compose.production.yml up --scale celeryworker=2
.. warning:: don't try to scale ``postgres``, ``celerybeat``, or ``traefik``.
To see how your containers are doing run::
- docker compose -f production.yml ps
+ docker compose -f docker-compose.production.yml ps
Example: Supervisor
@@ -165,12 +165,12 @@ 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 docker-compose.production.yml up`` in your projects root directory.
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
+ command=docker compose -f docker-compose.production.yml up
directory=/path/to/{{cookiecutter.project_slug}}
redirect_stderr=true
autostart=true
diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst
index a8f945adf..83de99bb9 100644
--- a/docs/developing-locally-docker.rst
+++ b/docs/developing-locally-docker.rst
@@ -32,9 +32,9 @@ Build the Stack
This can take a while, especially the first time you run this particular command on your development system::
- $ docker compose -f local.yml build
+ $ docker compose -f docker-compose.local.yml build
-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!
+Generally, if you want to emulate production environment use ``docker-compose.production.yml`` instead. And this is true for any other actions you might need to perform: whenever a switch is required, just do it!
Before doing any git commit, `pre-commit`_ should be installed globally on your local machine, and then::
@@ -51,11 +51,11 @@ This brings up both Django and PostgreSQL. The first time it is run it might tak
Open a terminal at the project root and run the following for local development::
- $ docker compose -f local.yml up
+ $ docker compose -f docker-compose.local.yml up
-You can also set the environment variable ``COMPOSE_FILE`` pointing to ``local.yml`` like this::
+You can also set the environment variable ``COMPOSE_FILE`` pointing to ``docker-compose.local.yml`` like this::
- $ export COMPOSE_FILE=local.yml
+ $ export COMPOSE_FILE=docker-compose.local.yml
And then run::
@@ -65,16 +65,23 @@ To run in a detached (background) mode, just::
$ docker compose up -d
+These commands don't run the docs service. In order to run docs service you can run::
+
+ $ docker compose -f docker-compose.docs.yml up
+
+To run the docs with local services just use::
+
+ $ docker compose -f docker-compose.local.yml -f docker-compose.docs.yml up
The site should start and be accessible at http://localhost:3000 if you selected Webpack or Gulp as frontend pipeline and http://localhost:8000 otherwise.
Execute 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: ::
+As with any shell command that we wish to run in our container, this is done using the ``docker compose -f docker-compose.local.yml run --rm`` command: ::
- $ docker compose -f local.yml run --rm django python manage.py migrate
- $ docker compose -f local.yml run --rm django python manage.py createsuperuser
+ $ docker compose -f docker-compose.local.yml run --rm django python manage.py migrate
+ $ docker compose -f docker-compose.local.yml run --rm django python manage.py createsuperuser
Here, ``django`` is the target service we are executing the commands against.
Also, please note that the ``docker exec`` does not work for running management commands.
@@ -90,7 +97,7 @@ When ``DEBUG`` is set to ``True``, the host is validated against ``['localhost',
Configuring the Environment
---------------------------
-This is the excerpt from your project's ``local.yml``: ::
+This is the excerpt from your project's ``docker-compose.local.yml``: ::
# ...
@@ -156,8 +163,8 @@ You have to modify the relevant requirement file: base, local or production by a
To get this change picked up, you'll need to rebuild the image(s) and restart the running container: ::
- docker compose -f local.yml build
- docker compose -f local.yml up
+ docker compose -f docker-compose.local.yml build
+ docker compose -f docker-compose.local.yml up
Debugging
~~~~~~~~~
@@ -171,7 +178,7 @@ If you are using the following within your code to debug: ::
Then you may need to run the following for it to work as desired: ::
- $ docker compose -f local.yml run --rm --service-ports django
+ $ docker compose -f docker-compose.local.yml run --rm --service-ports django
django-debug-toolbar
@@ -224,7 +231,7 @@ Prerequisites:
* ``use_docker`` was set to ``y`` on project initialization;
* ``use_celery`` was set to ``y`` on project initialization.
-By default, it's enabled both in local and production environments (``local.yml`` and ``production.yml`` Docker Compose configs, respectively) through a ``flower`` service. For added security, ``flower`` requires its clients to provide authentication credentials specified as the corresponding environments' ``.envs/.local/.django`` and ``.envs/.production/.django`` ``CELERY_FLOWER_USER`` and ``CELERY_FLOWER_PASSWORD`` environment variables. Check out ``localhost:5555`` and see for yourself.
+By default, it's enabled both in local and production environments (``docker-compose.local.yml`` and ``docker-compose.production.yml`` Docker Compose configs, respectively) through a ``flower`` service. For added security, ``flower`` requires its clients to provide authentication credentials specified as the corresponding environments' ``.envs/.local/.django`` and ``.envs/.production/.django`` ``CELERY_FLOWER_USER`` and ``CELERY_FLOWER_PASSWORD`` environment variables. Check out ``localhost:5555`` and see for yourself.
.. _`Flower`: https://github.com/mher/flower
@@ -272,7 +279,7 @@ certs
Take the certificates that you generated and place them in a folder called ``certs`` in the project's root folder. Assuming that you registered your local hostname as ``my-dev-env.local``, the certificates you will put in the folder should have the names ``my-dev-env.local.crt`` and ``my-dev-env.local.key``.
-local.yml
+docker-compose.local.yml
~~~~~~~~~
#. Add the ``nginx-proxy`` service. ::
@@ -316,7 +323,7 @@ You should allow the new hostname. ::
Rebuild your ``docker`` application. ::
- $ docker compose -f local.yml up -d --build
+ $ docker compose -f docker-compose.local.yml up -d --build
Go to your browser and type in your URL bar ``https://my-dev-env.local``
@@ -336,9 +343,9 @@ Webpack
If you are using Webpack:
-1. On the ``nginx-proxy`` service in ``local.yml``, change ``depends_on`` to ``node`` instead of ``django``.
+1. On the ``nginx-proxy`` service in ``docker-compose.local.yml``, change ``depends_on`` to ``node`` instead of ``django``.
-2. On the ``node`` service in ``local.yml``, add the following environment configuration:
+2. On the ``node`` service in ``docker-compose.local.yml``, add the following environment configuration:
::
diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst
index 92379f4fd..16247d082 100644
--- a/docs/developing-locally.rst
+++ b/docs/developing-locally.rst
@@ -9,7 +9,7 @@ Setting Up Development Environment
Make sure to have the following on your host:
-* Python 3.11
+* Python 3.12
* PostgreSQL_.
* Redis_, if using Celery
* Cookiecutter_
@@ -18,7 +18,7 @@ First things first.
#. Create a virtualenv: ::
- $ python3.11 -m venv
+ $ python3.12 -m venv
#. Activate the virtualenv you have just created: ::
@@ -96,6 +96,61 @@ First things first.
.. _direnv: https://direnv.net/
+Creating Your First Django App
+-------------------------------
+
+After setting up your environment, you're ready to add your first app. This project uses the setup from "Two Scoops of Django" with a two-tier layout:
+
+- **Top Level Repository Root** has config files, documentation, `manage.py`, and more.
+- **Second Level Django Project Root** is where your Django apps live.
+- **Second Level Configuration Root** holds settings and URL configurations.
+
+The project layout looks something like this: ::
+
+ /
+ ├── config/
+ │ ├── settings/
+ │ │ ├── __init__.py
+ │ │ ├── base.py
+ │ │ ├── local.py
+ │ │ └── production.py
+ │ ├── urls.py
+ │ └── wsgi.py
+ ├── /
+ │ ├── /
+ │ │ ├── migrations/
+ │ │ ├── admin.py
+ │ │ ├── apps.py
+ │ │ ├── models.py
+ │ │ ├── tests.py
+ │ │ └── views.py
+ │ ├── __init__.py
+ │ └── ...
+ ├── requirements/
+ │ ├── base.txt
+ │ ├── local.txt
+ │ └── production.txt
+ ├── manage.py
+ ├── README.md
+ └── ...
+
+
+Following this structured approach, here's how to add a new app:
+
+#. **Create the app** using Django's ``startapp`` command, replacing ```` with your desired app name: ::
+
+ $ python manage.py startapp
+
+#. **Move the app** to the Django Project Root, maintaining the project's two-tier structure: ::
+
+ $ mv /
+
+#. **Edit the app's apps.py** change ``name = ''`` to ``name = '.'``.
+
+#. **Register the new app** by adding it to the ``LOCAL_APPS`` list in ``config/settings/base.py``, integrating it as an official component of your project.
+
+
+
Setup Email Backend
-------------------
diff --git a/docs/docker-postgres-backups.rst b/docs/docker-postgres-backups.rst
index c40b6fd69..d214ee4e8 100644
--- a/docs/docker-postgres-backups.rst
+++ b/docs/docker-postgres-backups.rst
@@ -1,14 +1,14 @@
PostgreSQL Backups with Docker
==============================
-.. 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.
+.. 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 ``docker-compose.production.yml`` when needed.
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``.
+#. the stack is up and running: ``docker compose -f docker-compose.local.yml up -d postgres``.
Creating a Backup
@@ -16,7 +16,7 @@ Creating a Backup
To create a backup, run::
- $ docker compose -f local.yml exec postgres backup
+ $ docker compose -f docker-compose.local.yml exec postgres backup
Assuming your project's database is named ``my_project`` here is what you will see: ::
@@ -31,7 +31,7 @@ Viewing the Existing Backups
To list existing backups, ::
- $ docker compose -f local.yml exec postgres backups
+ $ docker compose -f docker-compose.local.yml exec postgres backups
These are the sample contents of ``/backups``: ::
@@ -55,9 +55,9 @@ With a single backup file copied to ``.`` that would be ::
$ docker cp 9c5c3f055843:/backups/backup_2018_03_13T09_05_07.sql.gz .
-You can also get the container ID using ``docker compose -f local.yml ps -q postgres`` so if you want to automate your backups, you don't have to check the container ID manually every time. Here is the full command ::
+You can also get the container ID using ``docker compose -f docker-compose.local.yml ps -q postgres`` so if you want to automate your backups, you don't have to check the container ID manually every time. Here is the full command ::
- $ docker cp $(docker compose -f local.yml ps -q postgres):/backups ./backups
+ $ docker cp $(docker compose -f docker-compose.local.yml ps -q postgres):/backups ./backups
.. _`command`: https://docs.docker.com/engine/reference/commandline/cp/
@@ -66,7 +66,7 @@ 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
+ $ docker compose -f docker-compose.local.yml exec postgres restore backup_2018_03_13T09_05_07.sql.gz
You will see something like ::
@@ -92,7 +92,36 @@ You will see something like ::
Backup to Amazon S3
----------------------------------
+
For uploading your backups to Amazon S3 you can use the aws cli container. There is an upload command for uploading the postgres /backups directory recursively and there is a download command for downloading a specific backup. The default S3 environment variables are used. ::
- $ docker compose -f production.yml run --rm awscli upload
- $ docker compose -f production.yml run --rm awscli download backup_2018_03_13T09_05_07.sql.gz
+ $ docker compose -f docker-compose.production.yml run --rm awscli upload
+ $ docker compose -f docker-compose.production.yml run --rm awscli download backup_2018_03_13T09_05_07.sql.gz
+
+Remove Backup
+----------------------------------
+
+To remove backup you can use the ``rmbackup`` command. This will remove the backup from the ``/backups`` directory. ::
+
+ $ docker compose -f docker-compose.local.yml exec postgres rmbackup backup_2018_03_13T09_05_07.sql.gz
+
+
+Upgrading PostgreSQL
+----------------------------------
+
+Upgrading PostgreSQL in your project requires a series of carefully executed steps. Start by halting all containers, excluding the postgres container. Following this, create a backup and proceed to remove the outdated data volume. ::
+
+ $ docker compose -f docker-compose.local.yml down
+ $ docker compose -f docker-compose.local.yml up -d postgres
+ $ docker compose -f docker-compose.local.yml run --rm postgres backup
+ $ docker compose -f docker-compose.local.yml down
+ $ docker volume rm my_project_postgres_data
+
+.. note:: Neglecting to remove the old data volume may lead to issues, such as the new postgres container failing to start with errors like ``FATAL: database files are incompatible with server``, and ``could not translate host name "postgres" to address: Name or service not known``.
+
+To complete the upgrade, update the PostgreSQL version in the corresponding Dockerfile (e.g. ``compose/production/postgres/Dockerfile``) and build a new version of PostgreSQL. ::
+
+ $ docker compose -f docker-compose.local.yml build postgres
+ $ docker compose -f docker-compose.local.yml up -d postgres
+ $ docker compose -f docker-compose.local.yml run --rm postgres restore backup_2018_03_13T09_05_07.sql.gz
+ $ docker compose -f docker-compose.local.yml up -d
diff --git a/docs/document.rst b/docs/document.rst
index 26f5d56a1..61cb692d3 100644
--- a/docs/document.rst
+++ b/docs/document.rst
@@ -11,7 +11,7 @@ After you have set up to `develop locally`_, run the following command from the
If you set up your project to `develop locally with docker`_, run the following command: ::
- $ docker compose -f local.yml up docs
+ $ docker compose -f docker-compose.docs.yml up
Navigate to port 9000 on your host to see the documentation. This will be opened automatically at `localhost`_ for local, non-docker development.
diff --git a/docs/faq.rst b/docs/faq.rst
index 52a99467c..294e6c8e1 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -22,6 +22,6 @@ TODO
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 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.
+You may notice that some elements of this project do not exactly match what we describe in chapter 3 of `Two Scoops of Django 3.x`_. 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 1.11: https://www.feldroy.com/collections/django/products/two-scoops-of-django-1-11
+.. _Two Scoops of Django 3.x: https://www.feldroy.com/two-scoops-press#two-scoops-of-django
diff --git a/docs/index.rst b/docs/index.rst
index da5186487..70daa1852 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -28,6 +28,7 @@ Contents
faq
troubleshooting
contributing
+ maintainer-guide
Indices and tables
------------------
diff --git a/docs/linters.rst b/docs/linters.rst
index a4f60cc8d..1fc44f30b 100644
--- a/docs/linters.rst
+++ b/docs/linters.rst
@@ -4,40 +4,30 @@ Linters
.. index:: linters
-flake8
+ruff
------
-To run flake8: ::
+Ruff is a Python linter and code formatter, written in Rust.
+It is a aggregation of flake8, pylint, pyupgrade and many more.
- $ flake8
+Ruff comes with a linter (``ruff check``) and a formatter (``ruff format``).
+The linter is a wrapper around flake8, pylint, and other linters,
+and the formatter is a wrapper around black, isort, and other formatters.
-The config for flake8 is located in setup.cfg. It specifies:
+To run ruff without modifying your files: ::
-* Set max line length to 120 chars
-* Exclude ``.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules``
+ $ ruff format --diff .
+ $ ruff check .
-pylint
-------
+Ruff is capable of fixing most of the problems it encounters.
+Be sure you commit first before running `ruff` so you can restore to a savepoint (and amend afterwards to prevent a double commit. : ::
-To run pylint: ::
+ $ ruff format .
+ $ ruff check --fix .
+ # be careful with the --unsafe-fixes option, it can break your code
+ $ ruff check --fix --unsafe-fixes .
- $ pylint
-
-The config for pylint is located in .pylintrc. It specifies:
-
-* Use the pylint_django plugin. If using Celery, also use pylint_celery.
-* Set max line length to 120 chars
-* Disable linting messages for missing docstring and invalid name
-* max-parents=13
-
-pycodestyle
------------
-
-This is included in flake8's checks, but you can also run it separately to see a more detailed report: ::
-
- $ pycodestyle
-
-The config for pycodestyle is located in setup.cfg. It specifies:
-
-* Set max line length to 120 chars
-* Exclude ``.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules``
+The config for ruff is located in pyproject.toml.
+On of the most important option is `tool.ruff.lint.select`.
+`select` determines which linters are run. In example, `DJ `_ refers to flake8-django.
+For a full list of available linters, see `https://docs.astral.sh/ruff/rules/ `_
diff --git a/docs/maintainer-guide.md b/docs/maintainer-guide.md
new file mode 100644
index 000000000..9baac688a
--- /dev/null
+++ b/docs/maintainer-guide.md
@@ -0,0 +1,104 @@
+# Maintainer guide
+
+This document is intended for maintainers of the template.
+
+## Automated updates
+
+We use 2 separate services to keep our dependencies up-to-date:
+
+- Dependabot, which manages updates of Python deps of the template, GitHub actions, npm packages and Docker images.
+- PyUp, which manages the Python deps for the generated project.
+
+We don't use Dependabot for the generated project deps because our requirements files are templated, and Dependabot fails to parse them. PyUp is -AFAIK- the only service out there that supports having Jinja tags in the requirements file.
+
+Updates for the template should be labelled as `project infrastructure` while the ones about the generated project should be labelled as `update`. This is use to work in conjunction with our changelog script (see later).
+
+## Automation scripts
+
+We have a few workflows which have been automated over time. They usually run using GitHub actions and might need a few small manual actions to work nicely. Some have a few limitations which we should document here.
+
+### CI
+
+`ci.yml`
+
+The CI workflow tries to cover 2 main aspects of the template:
+
+- Check all combinations to make sure that valid files are generated with no major linting issues. Issues which are fixed by an auto-formatter after generation aren't considered major, and only aim for best effort. This is under the `test` job.
+- Run more in-depth tests on a few combinations, by installing dependencies, running type checker and the test suite of the generated project. We try to cover docker (`docker` job) and non-docker (`bare` job) setups.
+
+We also run the deployment checks, but we don't do much more beyond that for testing the production setup.
+
+### Django issue checker
+
+`django-issue-checker.yml`
+
+This workflow runs daily, on schedule, and checks if there is a new major version of Django (not in the pure SemVer sense) released that we are not running, and list our dependencies compatibility.
+
+For example, at time of writing, we use Django 4.2, but the latest version of Django is 5.0, so the workflow created a ["Django 5.0" issue](https://github.com/cookiecutter/cookiecutter-django/issues/4724) in GitHub, with a compatibility table and keeps it up to date every day.
+
+#### Limitations
+
+Here are a few current and past limitations of the script
+
+- When a new dependency is added to the template, the script fails to update an existing issue
+- Not sure what happens when a deps is removed
+- ~~Unable to parse classifiers without minor version~~
+- ~~Creates an issue even if we are on the latest version~~
+
+### Issue manager
+
+`issue-manager.yml`
+
+A workflow that uses [Sebastian Ramirez' issue-manager](https://github.com/tiangolo/issue-manager) to help us automate issue management. The tag line from the repo explains it well:
+
+> Automatically close issues or Pull Requests that have a label, after a custom delay, if no one replies back.
+
+It runs on a schedule as well as when some actions are taken on issues and pull requests.
+
+We wait 10 days before closing issues, and we have a few customised reasons, which are configured in the workflow itself. The config should be fairly self-explanatory.
+
+### Pre-commit auto-update
+
+`pre-commit-autoupdate.yml`
+
+Run daily, to do `pre-commit autoupdate` on the template as well as the generated project, and opens a pull request with the changes.
+
+#### Limitations
+
+- The PR is open as GitHub action which means that CI does NOT run. The documentation for create-pull-request action [explains why](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs).
+- Some hooks are also installed as local dependencies (via `requirements/local.txt`), but these are updated separately via PyUP.
+
+### Update changelog
+
+`update-changelog.yml`
+
+Run daily at 2AM to update our changelog and create a GitHub release. This runs a custom script which:
+
+- List all pull requests merged the day before
+- The release name is calendar based, so `YYYY.MM.DD`
+- For each PR:
+ - Get the PR title to summarize the change
+ - Look at the PR labels to classify it in a section of the release notes:
+ - anything labelled `project infrastructure` is excluded
+ - label `update` goes in section "Updated"
+ - label `bug` goes in section "Fixed"
+ - label `docs` goes in section "Documentation"
+ - Default to section "Changed"
+
+With that in mind, when merging changes, it's a good idea to set the labels and rename the PR title to give a good summary of the change, in the context of the changelog.
+
+#### Limitations
+
+- Dependabot updates for npm & Docker have a verbose title, try to rename them to be more readable: `Bump webpack-dev-server from 4.15.1 to 5.0.2 in /{{cookiecutter.project_slug}}` -> `Bump webpack-dev-server to 5.0.2`
+- ~~Dependencies updates for the template repo (tox, cookiecutter, etc...) don't need to appear in changelog, and need to be labelled as `project infrastructure` manually. By default, they come from PyUp labelled as `update`.~~
+
+### Update contributors
+
+`update-contributors.yml`
+
+Runs on each push to master branch. List the 5 most recently merged pull requests and extract their author. If any of the authors is a new one, updates the `.github/contributors.json`, regenerate the `CONTRIBUTORS.md` from it, and push back the changes to master.
+
+#### Limitations
+
+- If you merge a pull request from a new contributor, and merge another one right after, the push to master will fail as the remote will be out of date.
+- If you merge more than 5 pull requests in a row like this, the new contributor might fail to be added.
diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst
index 967b42426..21059d3a2 100644
--- a/docs/project-generation-options.rst
+++ b/docs/project-generation-options.rst
@@ -66,12 +66,11 @@ use_docker:
postgresql_version:
Select a PostgreSQL_ version to use. The choices are:
- 1. 15
- 2. 14
- 3. 13
- 4. 12
- 5. 11
- 6. 10
+ 1. 16
+ 2. 15
+ 3. 14
+ 4. 13
+ 5. 12
cloud_provider:
Select a cloud provider for static & media files. The choices are:
@@ -92,7 +91,7 @@ mail_service:
4. Mandrill_
5. Postmark_
6. SendGrid_
- 7. SendinBlue_
+ 7. `Brevo (formerly SendinBlue)`_
8. SparkPost_
9. `Other SMTP`_
@@ -175,7 +174,7 @@ debug:
.. _Mandrill: http://mandrill.com
.. _Postmark: https://postmarkapp.com
.. _SendGrid: https://sendgrid.com
-.. _SendinBlue: https://www.sendinblue.com
+.. _Brevo (formerly SendinBlue): https://www.brevo.com
.. _SparkPost: https://www.sparkpost.com
.. _Other SMTP: https://anymail.readthedocs.io/en/stable/
diff --git a/docs/requirements.txt b/docs/requirements.txt
index 38a8385fd..26cb8da1b 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,3 +1,3 @@
-sphinx==7.2.6
-sphinx-rtd-theme==1.3.0
-myst-parser==2.0.0
+sphinx==7.3.7
+sphinx-rtd-theme==2.0.0
+myst-parser==3.0.1
diff --git a/docs/settings.rst b/docs/settings.rst
index 0880bce95..2be79cbf5 100644
--- a/docs/settings.rst
+++ b/docs/settings.rst
@@ -69,8 +69,8 @@ SENDGRID_API_KEY SENDGRID_API_KEY n/a
SENDGRID_GENERATE_MESSAGE_ID True n/a raises error
SENDGRID_MERGE_FIELD_FORMAT None n/a raises error
SENDGRID_API_URL n/a n/a "https://api.sendgrid.com/v3/"
-SENDINBLUE_API_KEY SENDINBLUE_API_KEY n/a raises error
-SENDINBLUE_API_URL n/a n/a "https://api.sendinblue.com/v3/"
+BREVO_API_KEY BREVO_API_KEY n/a raises error
+BREVO_API_URL n/a n/a "https://api.brevo.com/v3/"
SPARKPOST_API_KEY SPARKPOST_API_KEY n/a raises error
SPARKPOST_API_URL n/a n/a "https://api.sparkpost.com/api/v1"
======================================= =========================== ============================================== ======================================================================
diff --git a/docs/testing.rst b/docs/testing.rst
index 6387a6e1e..58a05770a 100644
--- a/docs/testing.rst
+++ b/docs/testing.rst
@@ -19,7 +19,7 @@ You will get a readout of the `users` app that has already been set up with test
If you set up your project to `develop locally with docker`_, run the following command: ::
- $ docker compose -f local.yml run --rm django pytest
+ $ docker compose -f docker-compose.local.yml run --rm django pytest
Targeting particular apps for testing in ``docker`` follows a similar pattern as previously shown above.
@@ -36,14 +36,14 @@ Once the tests are complete, in order to see the code coverage, run the followin
If you're running the project locally with Docker, use these commands instead: ::
- $ docker compose -f local.yml run --rm django coverage run -m pytest
- $ docker compose -f local.yml run --rm django coverage report
+ $ docker compose -f docker-compose.local.yml run --rm django coverage run -m pytest
+ $ docker compose -f docker-compose.local.yml run --rm django coverage report
.. note::
At the root of the project folder, you will find the `pytest.ini` file. You can use this to customize_ the ``pytest`` to your liking.
- There is also the `.coveragerc`. This is the configuration file for the ``coverage`` tool. You can find out more about `configuring`_ ``coverage``.
+ The configuration for ``coverage`` can be found in ``pyproject.toml``. You can find out more about `configuring`_ ``coverage``.
.. seealso::
diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst
index 80bab2e29..847f0a701 100644
--- a/docs/troubleshooting.rst
+++ b/docs/troubleshooting.rst
@@ -30,7 +30,7 @@ If you recreate the project multiple times with the same name, Docker would pres
To fix this, you can either:
-- Clear your project-related Docker cache with ``docker compose -f local.yml down --volumes --rmi all``.
+- Clear your project-related Docker cache with ``docker compose -f docker-compose.local.yml down --volumes --rmi all``.
- Use the Docker volume sub-commands to find volumes (`ls`_) and remove them (`rm`_).
- Use the `prune`_ command to clear system-wide (use with care!).
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
index 37f96efc0..9e9af5f2d 100644
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -8,6 +8,7 @@ NOTE:
TODO: restrict Cookiecutter Django project initialization to
Python 3.x environments only
"""
+
from __future__ import print_function
import json
@@ -77,7 +78,11 @@ def remove_docker_files():
shutil.rmtree(".devcontainer")
shutil.rmtree("compose")
- file_names = ["local.yml", "production.yml", ".dockerignore"]
+ file_names = [
+ "docker-compose.local.yml",
+ "docker-compose.production.yml",
+ ".dockerignore",
+ ]
for file_name in file_names:
os.remove(file_name)
if "{{ cookiecutter.editor }}" == "PyCharm":
@@ -429,10 +434,6 @@ def remove_drf_starter_files():
os.remove(os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "test_swagger.py"))
-def remove_storages_module():
- os.remove(os.path.join("{{cookiecutter.project_slug}}", "utils", "storages.py"))
-
-
def main():
debug = "{{ cookiecutter.debug }}".lower() == "y"
@@ -499,7 +500,6 @@ def main():
WARNING + "You chose to not use any cloud providers nor Docker, "
"media files won't be served in production." + TERMINATOR
)
- remove_storages_module()
if "{{ cookiecutter.use_celery }}".lower() == "n":
remove_celery_files()
diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py
index 33dc2e834..e58fd3541 100644
--- a/hooks/pre_gen_project.py
+++ b/hooks/pre_gen_project.py
@@ -7,6 +7,7 @@ NOTE:
TODO: restrict Cookiecutter Django project initialization
to Python 3.x environments only
"""
+
from __future__ import print_function
import sys
@@ -38,7 +39,7 @@ if "{{ cookiecutter.use_docker }}".lower() == "n":
if python_major_version == 2:
print(
WARNING + "You're running cookiecutter under Python 2, but the generated "
- "project requires Python 3.11+. Do you want to proceed (y/n)? " + TERMINATOR
+ "project requires Python 3.12+. Do you want to proceed (y/n)? " + TERMINATOR
)
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
while True:
diff --git a/pyproject.toml b/pyproject.toml
index 2a9f00b29..6e68762f7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -15,7 +15,7 @@ norecursedirs = [
# ==== black ====
[tool.black]
line-length = 119
-target-version = ['py311']
+target-version = ['py312']
# ==== isort ====
diff --git a/requirements.txt b/requirements.txt
index 198cf3ab2..cd8a823f8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,28 +1,26 @@
-cookiecutter==2.4.0
-sh==2.0.6; sys_platform != "win32"
+cookiecutter==2.6.0
+sh==2.0.7; sys_platform != "win32"
binaryornot==0.4.4
# Code quality
# ------------------------------------------------------------------------------
-black==23.9.1
-isort==5.12.0
-flake8==6.1.0
-django-upgrade==1.15.0
-djlint==1.34.0
-pre-commit==3.4.0
+ruff==0.4.9
+django-upgrade==1.18.0
+djlint==1.34.1
+pre-commit==3.7.1
# Testing
# ------------------------------------------------------------------------------
-tox==4.11.3
-pytest==7.4.2
-pytest-xdist==3.3.1
+tox==4.15.1
+pytest==8.2.2
+pytest-xdist==3.6.1
pytest-cookies==0.7.0
pytest-instafail==0.5.0
pyyaml==6.0.1
# Scripting
# ------------------------------------------------------------------------------
-PyGithub==2.1.1
-gitpython==3.1.37
-jinja2==3.1.2
-requests==2.31.0
+PyGithub==2.3.0
+gitpython==3.1.43
+jinja2==3.1.4
+requests==2.32.3
diff --git a/scripts/create_django_issue.py b/scripts/create_django_issue.py
index 236a126fb..2e59f18b0 100644
--- a/scripts/create_django_issue.py
+++ b/scripts/create_django_issue.py
@@ -6,6 +6,7 @@ patches, only comparing major and minor version numbers.
This script handles when there are multiple Django versions that need
to keep up to date.
"""
+
from __future__ import annotations
import os
@@ -212,7 +213,7 @@ class GitHubManager:
for classifier in package_info["info"]["classifiers"]:
# Usually in the form of "Framework :: Django :: 3.2"
tokens = classifier.split(" ")
- if len(tokens) >= 5 and tokens[2].lower() == "django":
+ if len(tokens) >= 5 and tokens[2].lower() == "django" and "." in tokens[4]:
version = DjVersion.parse(tokens[4])
if len(version) == 2:
supported_dj_versions.append(version)
diff --git a/scripts/update_contributors.py b/scripts/update_contributors.py
index 09a7082c0..7f7b48d76 100644
--- a/scripts/update_contributors.py
+++ b/scripts/update_contributors.py
@@ -40,8 +40,8 @@ def iter_recent_authors():
"""
Fetch users who opened recently merged pull requests.
- Use Github API to fetch recent authors rather than
- git CLI to work with Github usernames.
+ Use GitHub API to fetch recent authors rather than
+ git CLI to work with GitHub usernames.
"""
repo = Github(login_or_token=GITHUB_TOKEN, per_page=5).get_repo(GITHUB_REPO)
recent_pulls = repo.get_pulls(state="closed", sort="updated", direction="desc").get_page(0)
diff --git a/setup.py b/setup.py
index cc4d9a0ab..e240446f8 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ except ImportError:
from distutils.core import setup
# We use calendar versioning
-version = "2023.09.29"
+version = "2024.06.15"
with open("README.md") as readme_file:
long_description = readme_file.read()
@@ -30,7 +30,7 @@ setup(
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development",
],
diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py
index 31d006bed..5a0bca383 100755
--- a/tests/test_cookiecutter_generation.py
+++ b/tests/test_cookiecutter_generation.py
@@ -57,12 +57,11 @@ SUPPORTED_COMBINATIONS = [
{"editor": "VS Code"},
{"use_docker": "y"},
{"use_docker": "n"},
+ {"postgresql_version": "16"},
{"postgresql_version": "15"},
{"postgresql_version": "14"},
{"postgresql_version": "13"},
{"postgresql_version": "12"},
- {"postgresql_version": "11"},
- {"postgresql_version": "10"},
{"cloud_provider": "AWS", "use_whitenoise": "y"},
{"cloud_provider": "AWS", "use_whitenoise": "n"},
{"cloud_provider": "GCP", "use_whitenoise": "y"},
@@ -74,7 +73,7 @@ SUPPORTED_COMBINATIONS = [
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mandrill"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Postmark"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Sendgrid"},
- {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "SendinBlue"},
+ {"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Brevo"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "SparkPost"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Other SMTP"},
# Note: cloud_provider=None AND use_whitenoise=n is not supported
@@ -84,7 +83,7 @@ SUPPORTED_COMBINATIONS = [
{"cloud_provider": "AWS", "mail_service": "Mandrill"},
{"cloud_provider": "AWS", "mail_service": "Postmark"},
{"cloud_provider": "AWS", "mail_service": "Sendgrid"},
- {"cloud_provider": "AWS", "mail_service": "SendinBlue"},
+ {"cloud_provider": "AWS", "mail_service": "Brevo"},
{"cloud_provider": "AWS", "mail_service": "SparkPost"},
{"cloud_provider": "AWS", "mail_service": "Other SMTP"},
{"cloud_provider": "GCP", "mail_service": "Mailgun"},
@@ -92,7 +91,7 @@ SUPPORTED_COMBINATIONS = [
{"cloud_provider": "GCP", "mail_service": "Mandrill"},
{"cloud_provider": "GCP", "mail_service": "Postmark"},
{"cloud_provider": "GCP", "mail_service": "Sendgrid"},
- {"cloud_provider": "GCP", "mail_service": "SendinBlue"},
+ {"cloud_provider": "GCP", "mail_service": "Brevo"},
{"cloud_provider": "GCP", "mail_service": "SparkPost"},
{"cloud_provider": "GCP", "mail_service": "Other SMTP"},
{"cloud_provider": "Azure", "mail_service": "Mailgun"},
@@ -100,7 +99,7 @@ SUPPORTED_COMBINATIONS = [
{"cloud_provider": "Azure", "mail_service": "Mandrill"},
{"cloud_provider": "Azure", "mail_service": "Postmark"},
{"cloud_provider": "Azure", "mail_service": "Sendgrid"},
- {"cloud_provider": "Azure", "mail_service": "SendinBlue"},
+ {"cloud_provider": "Azure", "mail_service": "Brevo"},
{"cloud_provider": "Azure", "mail_service": "SparkPost"},
{"cloud_provider": "Azure", "mail_service": "Other SMTP"},
# Note: cloud_providers GCP, Azure, and None
@@ -180,28 +179,25 @@ def test_project_generation(cookies, context, context_override):
@pytest.mark.parametrize("context_override", SUPPORTED_COMBINATIONS, ids=_fixture_id)
-def test_flake8_passes(cookies, context_override):
- """Generated project should pass flake8."""
+def test_ruff_check_passes(cookies, context_override):
+ """Generated project should pass ruff check."""
result = cookies.bake(extra_context=context_override)
try:
- sh.flake8(_cwd=str(result.project_path))
+ sh.ruff("check", ".", _cwd=str(result.project_path))
except sh.ErrorReturnCode as e:
pytest.fail(e.stdout.decode())
@auto_fixable
@pytest.mark.parametrize("context_override", SUPPORTED_COMBINATIONS, ids=_fixture_id)
-def test_black_passes(cookies, context_override):
- """Check whether generated project passes black style."""
+def test_ruff_format_passes(cookies, context_override):
+ """Check whether generated project passes ruff format."""
result = cookies.bake(extra_context=context_override)
try:
- sh.black(
- "--check",
- "--diff",
- "--exclude",
- "migrations",
+ sh.ruff(
+ "format",
".",
_cwd=str(result.project_path),
)
@@ -251,7 +247,13 @@ def test_djlint_lint_passes(cookies, context_override):
# TODO: remove T002 when fixed https://github.com/Riverside-Healthcare/djLint/issues/687
ignored_rules = "H006,H030,H031,T002"
try:
- sh.djlint("--lint", "--ignore", f"{autofixable_rules},{ignored_rules}", ".", _cwd=str(result.project_path))
+ sh.djlint(
+ "--lint",
+ "--ignore",
+ f"{autofixable_rules},{ignored_rules}",
+ ".",
+ _cwd=str(result.project_path),
+ )
except sh.ErrorReturnCode as e:
pytest.fail(e.stdout.decode())
@@ -272,7 +274,7 @@ def test_djlint_check_passes(cookies, context_override):
["use_docker", "expected_test_script"],
[
("n", "pytest"),
- ("y", "docker compose -f local.yml run django pytest"),
+ ("y", "docker compose -f docker-compose.local.yml run django pytest"),
],
)
def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_script):
@@ -287,7 +289,7 @@ def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_scrip
with open(f"{result.project_path}/.travis.yml") as travis_yml:
try:
yml = yaml.safe_load(travis_yml)["jobs"]["include"]
- assert yml[0]["script"] == ["flake8"]
+ assert yml[0]["script"] == ["ruff check ."]
assert yml[1]["script"] == [expected_test_script]
except yaml.YAMLError as e:
pytest.fail(str(e))
@@ -297,7 +299,7 @@ def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_scrip
["use_docker", "expected_test_script"],
[
("n", "pytest"),
- ("y", "docker compose -f local.yml run django pytest"),
+ ("y", "docker compose -f docker-compose.local.yml run django pytest"),
],
)
def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expected_test_script):
@@ -324,7 +326,7 @@ def test_gitlab_invokes_precommit_and_pytest(cookies, context, use_docker, expec
["use_docker", "expected_test_script"],
[
("n", "pytest"),
- ("y", "docker compose -f local.yml run django pytest"),
+ ("y", "docker compose -f docker-compose.local.yml run django pytest"),
],
)
def test_github_invokes_linter_and_pytest(cookies, context, use_docker, expected_test_script):
diff --git a/tests/test_docker.sh b/tests/test_docker.sh
index 8e4055e20..473eede04 100755
--- a/tests/test_docker.sh
+++ b/tests/test_docker.sh
@@ -15,28 +15,38 @@ cookiecutter ../../ --no-input --overwrite-if-exists use_docker=y "$@"
cd my_awesome_project
# make sure all images build
-docker compose -f local.yml build
+docker compose -f docker-compose.local.yml build
# run the project's type checks
-docker compose -f local.yml run django mypy my_awesome_project
+docker compose -f docker-compose.local.yml run django mypy my_awesome_project
# run the project's tests
-docker compose -f local.yml run django pytest
+docker compose -f docker-compose.local.yml run django pytest
# 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; }
+docker compose -f docker-compose.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 --all
+docker compose -f docker-compose.local.yml run django python manage.py makemessages --all
# Make sure the check doesn't raise any warnings
-docker compose -f local.yml run django python manage.py check --fail-level WARNING
+docker compose -f docker-compose.local.yml run \
+ -e DJANGO_SECRET_KEY="$(openssl rand -base64 64)" \
+ -e REDIS_URL=redis://redis:6379/0 \
+ -e CELERY_BROKER_URL=redis://redis:6379/0 \
+ -e DJANGO_AWS_ACCESS_KEY_ID=x \
+ -e DJANGO_AWS_SECRET_ACCESS_KEY=x \
+ -e DJANGO_AWS_STORAGE_BUCKET_NAME=x \
+ -e DJANGO_ADMIN_URL=x \
+ -e MAILGUN_API_KEY=x \
+ -e MAILGUN_DOMAIN=x \
+ django python manage.py check --settings=config.settings.production --deploy --database default --fail-level WARNING
# Generate the HTML for the documentation
-docker compose -f local.yml run docs make html
+docker compose -f docker-compose.docs.yml run docs make html
# Run npm build script if package.json is present
if [ -f "package.json" ]
then
- docker compose -f local.yml run node npm run build
+ docker compose -f docker-compose.local.yml run node npm run build
fi
diff --git a/tests/test_hooks.py b/tests/test_hooks.py
index 6afdc400b..2ccac84b2 100644
--- a/tests/test_hooks.py
+++ b/tests/test_hooks.py
@@ -1,4 +1,5 @@
"""Unit tests for the hooks"""
+
import os
from pathlib import Path
diff --git a/tox.ini b/tox.ini
index 903d5a53b..3b7a95088 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
[tox]
skipsdist = true
-envlist = py311,black-template
+envlist = py312,black-template
[testenv]
deps = -rrequirements.txt
diff --git a/{{cookiecutter.project_slug}}/.devcontainer/devcontainer.json b/{{cookiecutter.project_slug}}/.devcontainer/devcontainer.json
index 393408582..5604b8a85 100644
--- a/{{cookiecutter.project_slug}}/.devcontainer/devcontainer.json
+++ b/{{cookiecutter.project_slug}}/.devcontainer/devcontainer.json
@@ -2,7 +2,7 @@
{
"name": "{{cookiecutter.project_slug}}_dev",
"dockerComposeFile": [
- "../local.yml"
+ "../docker-compose.local.yml"
],
"init": true,
"mounts": [
@@ -11,11 +11,6 @@
"target": "/home/dev-user/.bash_history",
"type": "bind"
},
- {
- "source": "/tmp",
- "target": "/tmp",
- "type": "bind"
- },
{
"source": "~/.ssh",
"target": "/home/dev-user/.ssh",
@@ -40,24 +35,13 @@
"analysis.typeCheckingMode": "basic",
"defaultInterpreterPath": "/usr/local/bin/python",
"editor.codeActionsOnSave": {
- "source.organizeImports": true
+ "source.organizeImports": "always"
},
- // Uncomment when fixed
- // https://github.com/microsoft/vscode-remote-release/issues/8474
- // "editor.defaultFormatter": "ms-python.black-formatter",
- "formatting.blackPath": "/usr/local/bin/black",
- "formatting.provider": "black",
+ "editor.defaultFormatter": "charliermarsh.ruff",
"languageServer": "Pylance",
- // "linting.banditPath": "/usr/local/py-utils/bin/bandit",
"linting.enabled": true,
- "linting.flake8Enabled": true,
- "linting.flake8Path": "/usr/local/bin/flake8",
"linting.mypyEnabled": true,
"linting.mypyPath": "/usr/local/bin/mypy",
- "linting.pycodestylePath": "/usr/local/bin/pycodestyle",
- // "linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
- "linting.pylintEnabled": true,
- "linting.pylintPath": "/usr/local/bin/pylint"
}
},
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_vs-code-specific-properties
@@ -70,8 +54,7 @@
// python
"ms-python.python",
"ms-python.vscode-pylance",
- "ms-python.isort",
- "ms-python.black-formatter",
+ "charliermarsh.ruff",
// django
"batisteo.vscode-django"
]
diff --git a/{{cookiecutter.project_slug}}/.drone.yml b/{{cookiecutter.project_slug}}/.drone.yml
index dc08bfbab..d6c13e62b 100644
--- a/{{cookiecutter.project_slug}}/.drone.yml
+++ b/{{cookiecutter.project_slug}}/.drone.yml
@@ -13,7 +13,7 @@ environment:
steps:
- name: lint
pull: if-not-exists
- image: python:3.11
+ image: python:3.12
environment:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
volumes:
@@ -27,16 +27,17 @@ steps:
- name: test
pull: if-not-exists
{%- if cookiecutter.use_docker == 'y' %}
- image: docker/compose:1.29.2
+ image: docker:25.0
environment:
DATABASE_URL: pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB
commands:
- - docker-compose -f local.yml build
- - docker-compose -f local.yml run --rm django python manage.py migrate
- - docker-compose -f local.yml up -d
- - docker-compose -f local.yml run django pytest
+ - docker-compose -f docker-compose.local.yml build
+ - docker-compose -f docker-compose.docs.yml build
+ - docker-compose -f docker-compose.local.yml run --rm django python manage.py migrate
+ - docker-compose -f docker-compose.local.yml up -d
+ - docker-compose -f docker-compose.local.yml run django pytest
{%- else %}
- image: python:3.11
+ image: python:3.12
commands:
- pip install -r requirements/local.txt
- pytest
diff --git a/{{cookiecutter.project_slug}}/.envs/.production/.django b/{{cookiecutter.project_slug}}/.envs/.production/.django
index ad652c9ad..07ffd7112 100644
--- a/{{cookiecutter.project_slug}}/.envs/.production/.django
+++ b/{{cookiecutter.project_slug}}/.envs/.production/.django
@@ -28,8 +28,8 @@ POSTMARK_SERVER_TOKEN=
SENDGRID_API_KEY=
SENDGRID_GENERATE_MESSAGE_ID=True
SENDGRID_MERGE_FIELD_FORMAT=None
-{% elif cookiecutter.mail_service == 'SendinBlue' %}
-SENDINBLUE_API_KEY=
+{% elif cookiecutter.mail_service == 'Brevo' %}
+BREVO_API_KEY=
{% elif cookiecutter.mail_service == 'SparkPost' %}
SPARKPOST_API_KEY=
{% endif %}
diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml
index e39933fe1..5cb9ead4f 100644
--- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml
+++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml
@@ -26,17 +26,17 @@ jobs:
uses: actions/checkout@v4
- name: Set up Python
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
- python-version: '3.11'
+ python-version: '3.12'
{%- if cookiecutter.open_source_license != 'Not open source' %}
# Consider using pre-commit.ci for open source project
{%- endif %}
- name: Run pre-commit
- uses: pre-commit/action@v3.0.0
+ uses: pre-commit/action@v3.0.1
- # With no caching at all the entire ci process takes 4m 30s to complete!
+ # With no caching at all the entire ci process takes 3m to complete!
pytest:
runs-on: ubuntu-latest
{%- if cookiecutter.use_docker == 'n' %}
@@ -69,22 +69,25 @@ jobs:
{%- if cookiecutter.use_docker == 'y' %}
- name: Build the Stack
- run: docker compose -f local.yml build
+ run: docker compose -f docker-compose.local.yml build django
+
+ - name: Build the docs
+ run: docker compose -f docker-compose.docs.yml build docs
- name: Run DB Migrations
- run: docker compose -f local.yml run --rm django python manage.py migrate
+ run: docker compose -f docker-compose.local.yml run --rm django python manage.py migrate
- name: Run Django Tests
- run: docker compose -f local.yml run django pytest
+ run: docker compose -f docker-compose.local.yml run django pytest
- name: Tear down the Stack
- run: docker compose -f local.yml down
+ run: docker compose -f docker-compose.local.yml down
{%- else %}
- name: Set up Python
uses: actions/setup-python@v4
with:
- python-version: '3.11'
+ python-version: '3.12'
cache: pip
cache-dependency-path: |
requirements/base.txt
diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
index 350212003..41eea0db4 100644
--- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml
+++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
@@ -13,7 +13,7 @@ variables:
precommit:
stage: lint
- image: python:3.11
+ image: python:3.12
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
cache:
@@ -27,20 +27,21 @@ precommit:
pytest:
stage: test
{%- if cookiecutter.use_docker == 'y' %}
- image: docker/compose:1.29.2
+ image: docker:25.0
tags:
- docker
services:
- docker:dind
before_script:
- - docker compose -f local.yml build
+ - docker compose -f docker-compose.local.yml build
+ - docker compose -f docker-compose.docs.yml build
# Ensure celerybeat does not crash due to non-existent tables
- - docker compose -f local.yml run --rm django python manage.py migrate
- - docker compose -f local.yml up -d
+ - docker compose -f docker-compose.local.yml run --rm django python manage.py migrate
+ - docker compose -f docker-compose.local.yml up -d
script:
- - docker compose -f local.yml run django pytest
+ - docker compose -f docker-compose.local.yml run django pytest
{%- else %}
- image: python:3.11
+ image: python:3.12
tags:
- python
services:
diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_django.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_django.xml
index e84c5ffdd..0eabd93c8 100644
--- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_django.xml
+++ b/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_django.xml
@@ -15,7 +15,7 @@
{%- endif %}
-
+
diff --git a/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_docs.xml b/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_docs.xml
index 0f77b28df..6134cf917 100644
--- a/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_docs.xml
+++ b/{{cookiecutter.project_slug}}/.idea/runConfigurations/docker_compose_up_docs.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml
index 01b6803e5..e9629f6da 100644
--- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml
+++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml
@@ -1,9 +1,12 @@
-exclude: '^docs/|/migrations/'
+exclude: '^docs/|/migrations/|devcontainer.json'
default_stages: [commit]
+default_language_version:
+ python: python3.12
+
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
+ rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@@ -18,41 +21,30 @@ repos:
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-prettier
- rev: v3.0.3
+ rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: ['--tab-width', '2', '--single-quote']
exclude: '{{cookiecutter.project_slug}}/templates/'
- repo: https://github.com/adamchainz/django-upgrade
- rev: '1.15.0'
+ rev: '1.18.0'
hooks:
- id: django-upgrade
args: ['--target-version', '4.2']
- - repo: https://github.com/asottile/pyupgrade
- rev: v3.14.0
+ # Run the Ruff linter.
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.4.9
hooks:
- - id: pyupgrade
- args: [--py311-plus]
-
- - repo: https://github.com/psf/black
- rev: 23.9.1
- hooks:
- - id: black
-
- - repo: https://github.com/PyCQA/isort
- rev: 5.12.0
- hooks:
- - id: isort
-
- - repo: https://github.com/PyCQA/flake8
- rev: 6.1.0
- hooks:
- - id: flake8
+ # Linter
+ - id: ruff
+ args: [--fix, --exit-non-zero-on-fix]
+ # Formatter
+ - id: ruff-format
- repo: https://github.com/Riverside-Healthcare/djLint
- rev: v1.34.0
+ rev: v1.34.1
hooks:
- id: djlint-reformat-django
- id: djlint-django
diff --git a/{{cookiecutter.project_slug}}/.readthedocs.yml b/{{cookiecutter.project_slug}}/.readthedocs.yml
index d5a8ef661..556438876 100644
--- a/{{cookiecutter.project_slug}}/.readthedocs.yml
+++ b/{{cookiecutter.project_slug}}/.readthedocs.yml
@@ -8,7 +8,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
- python: '3.11'
+ python: '3.12'
# Build documentation in the docs/ directory with Sphinx
sphinx:
diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml
index cd703d3ad..97f9f60a2 100644
--- a/{{cookiecutter.project_slug}}/.travis.yml
+++ b/{{cookiecutter.project_slug}}/.travis.yml
@@ -2,7 +2,7 @@ dist: focal
language: python
python:
- - "3.11"
+ - "3.12"
services:
- {% if cookiecutter.use_docker == 'y' %}docker{% else %}postgresql{% endif %}
@@ -10,23 +10,24 @@ jobs:
include:
- name: "Linter"
before_script:
- - pip install -q flake8
+ - pip install -q ruff
script:
- - "flake8"
+ - ruff check .
- name: "Django Test"
{%- if cookiecutter.use_docker == 'y' %}
before_script:
- docker compose -v
- docker -v
- - docker compose -f local.yml build
+ - docker compose -f docker-compose.local.yml build
+ - docker compose -f docker-compose.docs.yml build
# Ensure celerybeat does not crash due to non-existent tables
- - docker compose -f local.yml run --rm django python manage.py migrate
- - docker compose -f local.yml up -d
+ - docker compose -f docker-compose.local.yml run --rm django python manage.py migrate
+ - docker compose -f docker-compose.local.yml up -d
script:
- - "docker compose -f local.yml run django pytest"
+ - docker compose -f docker-compose.local.yml run django pytest
after_failure:
- - docker compose -f local.yml logs
+ - docker compose -f docker-compose.local.yml logs
{%- else %}
before_install:
- sudo apt-get update -qq
@@ -37,9 +38,9 @@ jobs:
- sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
language: python
python:
- - "3.11"
+ - "3.12"
install:
- pip install -r requirements/local.txt
script:
- - "pytest"
+ - pytest
{%- endif %}
diff --git a/{{cookiecutter.project_slug}}/Procfile b/{{cookiecutter.project_slug}}/Procfile
index 2f2fbe927..6424e048d 100644
--- a/{{cookiecutter.project_slug}}/Procfile
+++ b/{{cookiecutter.project_slug}}/Procfile
@@ -1,6 +1,6 @@
release: python manage.py migrate
{%- if cookiecutter.use_async == "y" %}
-web: gunicorn config.asgi:application -k uvicorn.workers.UvicornWorker
+web: gunicorn config.asgi:application -k uvicorn_worker.UvicornWorker
{%- else %}
web: gunicorn config.wsgi:application
{%- endif %}
diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md
index ccf245a2f..cb7576892 100644
--- a/{{cookiecutter.project_slug}}/README.md
+++ b/{{cookiecutter.project_slug}}/README.md
@@ -3,7 +3,7 @@
{{ cookiecutter.description }}
[](https://github.com/cookiecutter/cookiecutter-django/)
-[](https://github.com/ambv/black)
+[](https://github.com/astral-sh/ruff)
{%- if cookiecutter.open_source_license != "Not open source" %}
diff --git a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile
index deb3f5d61..b085d990c 100644
--- a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile
@@ -1,5 +1,5 @@
# define an alias for the specific python version used in this file.
-FROM python:3.11.6-slim-bullseye as python
+FROM docker.io/python:3.12.4-slim-bookworm as python
# Python build stage
FROM python as python-build-stage
@@ -10,7 +10,7 @@ ARG BUILD_ENVIRONMENT=local
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
- # psycopg2 dependencies
+ # psycopg dependencies
libpq-dev
# Requirements are installed here to ensure they will be cached.
@@ -47,7 +47,7 @@ RUN groupadd --gid 1000 dev-user \
# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
- # psycopg2 dependencies
+ # psycopg dependencies
libpq-dev \
# Translations dependencies
gettext \
diff --git a/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start b/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start
index b4783d2f0..cebb62203 100644
--- a/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start
+++ b/{{cookiecutter.project_slug}}/compose/local/django/celery/flower/start
@@ -3,6 +3,14 @@
set -o errexit
set -o nounset
+
+until timeout 10 celery -A config.celery_app inspect ping; do
+ >&2 echo "Celery workers not available"
+done
+
+echo 'Starting flower'
+
+
exec watchfiles --filter python celery.__main__.main \
--args \
"-A config.celery_app -b \"${CELERY_BROKER_URL}\" flower --basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\""
diff --git a/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile
index 1652ac2ce..0fadd009b 100644
--- a/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile
@@ -1,5 +1,5 @@
# define an alias for the specific python version used in this file.
-FROM python:3.11.5-slim-bullseye as python
+FROM docker.io/python:3.12.4-slim-bookworm as python
# Python build stage
@@ -10,7 +10,7 @@ ENV PYTHONDONTWRITEBYTECODE 1
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
- # psycopg2 dependencies
+ # psycopg dependencies
libpq-dev \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
@@ -35,7 +35,7 @@ ENV PYTHONDONTWRITEBYTECODE 1
RUN apt-get update && apt-get install --no-install-recommends -y \
# To run the Makefile
make \
- # psycopg2 dependencies
+ # psycopg dependencies
libpq-dev \
# Translations dependencies
gettext \
diff --git a/{{cookiecutter.project_slug}}/compose/local/node/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/node/Dockerfile
index 707ed0c9d..0848ecaf8 100644
--- a/{{cookiecutter.project_slug}}/compose/local/node/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/local/node/Dockerfile
@@ -1,4 +1,4 @@
-FROM node:18-bullseye-slim
+FROM docker.io/node:20-bookworm-slim
WORKDIR /app
diff --git a/{{cookiecutter.project_slug}}/compose/production/aws/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/aws/Dockerfile
index 4d1ecbb20..687c6d5cf 100644
--- a/{{cookiecutter.project_slug}}/compose/production/aws/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/production/aws/Dockerfile
@@ -1,4 +1,4 @@
-FROM garland/aws-cli-docker:1.16.140
+FROM docker.io/amazon/aws-cli:2.16.8
COPY ./compose/production/aws/maintenance /usr/local/bin/maintenance
COPY ./compose/production/postgres/maintenance/_sourced /usr/local/bin/maintenance/_sourced
diff --git a/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/download b/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/download
index 9561d917a..12871a773 100644
--- a/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/download
+++ b/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/download
@@ -3,7 +3,7 @@
### Download a file from your Amazon S3 bucket to the postgres /backups folder
###
### Usage:
-### $ docker compose -f production.yml run --rm awscli <1>
+### $ docker compose -f docker-compose.production.yml run --rm awscli <1>
set -o errexit
set -o pipefail
diff --git a/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/upload b/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/upload
index 73c1b9bec..2f577824e 100644
--- a/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/upload
+++ b/{{cookiecutter.project_slug}}/compose/production/aws/maintenance/upload
@@ -3,7 +3,7 @@
### Upload the /backups folder to Amazon S3
###
### Usage:
-### $ docker compose -f production.yml run --rm awscli upload
+### $ docker compose -f docker-compose.production.yml run --rm awscli upload
set -o errexit
set -o pipefail
diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile
index 6ddebbffe..ab83fcd8f 100644
--- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile
@@ -1,5 +1,5 @@
{% if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] -%}
-FROM node:18-bullseye-slim as client-builder
+FROM docker.io/node:20-bookworm-slim as client-builder
ARG APP_HOME=/app
WORKDIR ${APP_HOME}
@@ -25,7 +25,7 @@ RUN npm run build
{%- endif %}
# define an alias for the specific python version used in this file.
-FROM python:3.11.6-slim-bullseye as python
+FROM docker.io/python:3.12.4-slim-bookworm as python
# Python build stage
FROM python as python-build-stage
@@ -36,7 +36,7 @@ ARG BUILD_ENVIRONMENT=production
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
- # psycopg2 dependencies
+ # psycopg dependencies
libpq-dev
# Requirements are installed here to ensure they will be cached.
@@ -65,7 +65,7 @@ RUN addgroup --system django \
# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
- # psycopg2 dependencies
+ # psycopg dependencies
libpq-dev \
# Translations dependencies
gettext \
@@ -117,7 +117,7 @@ COPY --chown=django:django . ${APP_HOME}
{%- endif %}
# make django owner of the WORKDIR directory as well.
-RUN chown django:django ${APP_HOME}
+RUN chown -R django:django ${APP_HOME}
USER django
diff --git a/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start b/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start
index 4180d6778..f903a05a2 100644
--- a/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start
+++ b/{{cookiecutter.project_slug}}/compose/production/django/celery/flower/start
@@ -4,6 +4,14 @@ set -o errexit
set -o nounset
+
+until timeout 10 celery -A config.celery_app inspect ping; do
+ >&2 echo "Celery workers not available"
+done
+
+echo 'Starting flower'
+
+
exec celery \
-A config.celery_app \
-b "${CELERY_BROKER_URL}" \
diff --git a/{{cookiecutter.project_slug}}/compose/production/django/start b/{{cookiecutter.project_slug}}/compose/production/django/start
index 73f686bd7..38fc29b55 100644
--- a/{{cookiecutter.project_slug}}/compose/production/django/start
+++ b/{{cookiecutter.project_slug}}/compose/production/django/start
@@ -28,7 +28,7 @@ if compress_enabled; then
fi
{%- endif %}
{%- if cookiecutter.use_async == 'y' %}
-exec /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app -k uvicorn.workers.UvicornWorker
+exec /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:5000 --chdir=/app -k uvicorn_worker.UvicornWorker
{%- else %}
exec /usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app
{%- endif %}
diff --git a/{{cookiecutter.project_slug}}/compose/production/nginx/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/nginx/Dockerfile
index 911b16f71..ec2ad35cb 100644
--- a/{{cookiecutter.project_slug}}/compose/production/nginx/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/production/nginx/Dockerfile
@@ -1,2 +1,2 @@
-FROM nginx:1.17.8-alpine
+FROM docker.io/nginx:1.17.8-alpine
COPY ./compose/production/nginx/default.conf /etc/nginx/conf.d/default.conf
diff --git a/{{cookiecutter.project_slug}}/compose/production/postgres/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/postgres/Dockerfile
index eca29bada..5da8982f4 100644
--- a/{{cookiecutter.project_slug}}/compose/production/postgres/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/production/postgres/Dockerfile
@@ -1,4 +1,4 @@
-FROM postgres:{{ cookiecutter.postgresql_version }}
+FROM docker.io/postgres:{{ cookiecutter.postgresql_version }}
COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
RUN chmod +x /usr/local/bin/maintenance/*
diff --git a/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/rmbackup b/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/rmbackup
new file mode 100644
index 000000000..fdfd20e14
--- /dev/null
+++ b/{{cookiecutter.project_slug}}/compose/production/postgres/maintenance/rmbackup
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+### Remove a database backup.
+###
+### Parameters:
+### <1> filename of a backup to remove.
+###
+### Usage:
+### $ docker-compose -f .yml (exec |run --rm) postgres rmbackup <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 "Removing the '${backup_filename}' backup file..."
+
+rm -r "${backup_filename}"
+
+message_success "The '${backup_filename}' database backup has been removed."
diff --git a/{{cookiecutter.project_slug}}/compose/production/traefik/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/traefik/Dockerfile
index e547dfbb8..d54bf27ca 100644
--- a/{{cookiecutter.project_slug}}/compose/production/traefik/Dockerfile
+++ b/{{cookiecutter.project_slug}}/compose/production/traefik/Dockerfile
@@ -1,4 +1,4 @@
-FROM traefik:2.10.4
+FROM docker.io/traefik:2.11.2
RUN mkdir -p /etc/traefik/acme \
&& touch /etc/traefik/acme/acme.json \
&& chmod 600 /etc/traefik/acme/acme.json
diff --git a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml
index 724c95cdf..f5d9e52fc 100644
--- a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml
+++ b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml
@@ -6,7 +6,7 @@ entryPoints:
# http
address: ':80'
http:
- # https://docs.traefik.io/routing/entrypoints/#entrypoint
+ # https://doc.traefik.io/traefik/routing/entrypoints/#entrypoint
redirections:
entryPoint:
to: web-secure
@@ -22,11 +22,11 @@ entryPoints:
certificatesResolvers:
letsencrypt:
- # https://docs.traefik.io/master/https/acme/#lets-encrypt
+ # https://doc.traefik.io/traefik/https/acme/#lets-encrypt
acme:
email: '{{ cookiecutter.email }}'
storage: /etc/traefik/acme/acme.json
- # https://docs.traefik.io/master/https/acme/#httpchallenge
+ # https://doc.traefik.io/traefik/https/acme/#httpchallenge
httpChallenge:
entryPoint: web
@@ -44,7 +44,7 @@ http:
- csrf
service: django
tls:
- # https://docs.traefik.io/master/routing/routers/#certresolver
+ # https://doc.traefik.io/traefik/routing/routers/#certresolver
certResolver: letsencrypt
{%- if cookiecutter.use_celery == 'y' %}
@@ -54,7 +54,7 @@ http:
- flower
service: flower
tls:
- # https://docs.traefik.io/master/routing/routers/#certresolver
+ # https://doc.traefik.io/traefik/master/routing/routers/#certresolver
certResolver: letsencrypt
{%- endif %}
{%- if cookiecutter.cloud_provider == 'None' %}
@@ -76,7 +76,7 @@ http:
middlewares:
csrf:
- # https://docs.traefik.io/master/middlewares/headers/#hostsproxyheaders
+ # https://doc.traefik.io/traefik/master/middlewares/http/headers/#hostsproxyheaders
# https://docs.djangoproject.com/en/dev/ref/csrf/#ajax
headers:
hostsProxyHeaders: ['X-CSRFToken']
@@ -102,7 +102,7 @@ http:
{%- endif %}
providers:
- # https://docs.traefik.io/master/providers/file/
+ # https://doc.traefik.io/traefik/master/providers/file/
file:
filename: /etc/traefik/traefik.yml
watch: true
diff --git a/{{cookiecutter.project_slug}}/config/api_router.py b/{{cookiecutter.project_slug}}/config/api_router.py
index 743069b2c..d4de098fc 100644
--- a/{{cookiecutter.project_slug}}/config/api_router.py
+++ b/{{cookiecutter.project_slug}}/config/api_router.py
@@ -1,12 +1,10 @@
from django.conf import settings
-from rest_framework.routers import DefaultRouter, SimpleRouter
+from rest_framework.routers import DefaultRouter
+from rest_framework.routers import SimpleRouter
from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet
-if settings.DEBUG:
- router = DefaultRouter()
-else:
- router = SimpleRouter()
+router = DefaultRouter() if settings.DEBUG else SimpleRouter()
router.register("users", UserViewSet)
diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py
index 65e76ca0a..edfffbbc5 100644
--- a/{{cookiecutter.project_slug}}/config/asgi.py
+++ b/{{cookiecutter.project_slug}}/config/asgi.py
@@ -1,3 +1,4 @@
+# ruff: noqa
"""
ASGI config for {{ cookiecutter.project_name }} project.
@@ -7,6 +8,7 @@ For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/asgi/
"""
+
import os
import sys
from pathlib import Path
@@ -28,7 +30,7 @@ django_application = get_asgi_application()
# application = HelloWorldApplication(application)
# Import websocket application here, so apps from django_application are loaded first
-from config.websocket import websocket_application # noqa isort:skip
+from config.websocket import websocket_application
async def application(scope, receive, send):
@@ -37,4 +39,5 @@ async def application(scope, receive, send):
elif scope["type"] == "websocket":
await websocket_application(scope, receive, send)
else:
- raise NotImplementedError(f"Unknown scope type {scope['type']}")
+ msg = f"Unknown scope type {scope['type']}"
+ raise NotImplementedError(msg)
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
index 331ff06e2..f1039b748 100644
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -1,6 +1,6 @@
-"""
-Base settings to build other settings files upon.
-"""
+# ruff: noqa: ERA001, E501
+"""Base settings to build other settings files upon."""
+
from pathlib import Path
import environ
@@ -84,6 +84,7 @@ THIRD_PARTY_APPS = [
"crispy_bootstrap5",
"allauth",
"allauth.account",
+ "allauth.mfa",
"allauth.socialaccount",
{%- if cookiecutter.use_celery == 'y' %}
"django_celery_beat",
@@ -137,7 +138,9 @@ PASSWORD_HASHERS = [
]
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
- {"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
+ {
+ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
+ },
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
@@ -210,7 +213,7 @@ TEMPLATES = [
"{{cookiecutter.project_slug}}.users.context_processors.allauth_settings",
],
},
- }
+ },
]
# https://docs.djangoproject.com/en/dev/ref/settings/#form-renderer
@@ -274,7 +277,7 @@ LOGGING = {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
- }
+ },
},
"root": {"level": "INFO", "handlers": ["console"]},
}
@@ -319,25 +322,25 @@ CELERY_TASK_SEND_SENT_EVENT = True
# django-allauth
# ------------------------------------------------------------------------------
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True)
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/account/configuration.html
ACCOUNT_AUTHENTICATION_METHOD = "{{cookiecutter.username_type}}"
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/account/configuration.html
ACCOUNT_EMAIL_REQUIRED = True
{%- if cookiecutter.username_type == "email" %}
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/account/configuration.html
ACCOUNT_USERNAME_REQUIRED = False
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/account/configuration.html
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
{%- endif %}
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/account/configuration.html
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/account/configuration.html
ACCOUNT_ADAPTER = "{{cookiecutter.project_slug}}.users.adapters.AccountAdapter"
-# https://django-allauth.readthedocs.io/en/latest/forms.html
+# https://docs.allauth.org/en/latest/account/forms.html
ACCOUNT_FORMS = {"signup": "{{cookiecutter.project_slug}}.users.forms.UserSignupForm"}
-# https://django-allauth.readthedocs.io/en/latest/configuration.html
+# https://docs.allauth.org/en/latest/socialaccount/configuration.html
SOCIALACCOUNT_ADAPTER = "{{cookiecutter.project_slug}}.users.adapters.SocialAccountAdapter"
-# https://django-allauth.readthedocs.io/en/latest/forms.html
+# https://docs.allauth.org/en/latest/socialaccount/configuration.html
SOCIALACCOUNT_FORMS = {"signup": "{{cookiecutter.project_slug}}.users.forms.UserSocialSignupForm"}
{% if cookiecutter.frontend_pipeline == 'Django Compressor' -%}
# django-compressor
@@ -369,6 +372,7 @@ SPECTACULAR_SETTINGS = {
"DESCRIPTION": "Documentation of API endpoints of {{ cookiecutter.project_name }}",
"VERSION": "1.0.0",
"SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
+ "SCHEMA_PATH_PREFIX": "/api/",
}
{%- endif %}
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
@@ -380,7 +384,7 @@ WEBPACK_LOADER = {
"STATS_FILE": BASE_DIR / "webpack-stats.json",
"POLL_INTERVAL": 0.1,
"IGNORE": [r".+\.hot-update.js", r".+\.map"],
- }
+ },
}
{%- endif %}
diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py
index 0304d6cd4..f63151239 100644
--- a/{{cookiecutter.project_slug}}/config/settings/local.py
+++ b/{{cookiecutter.project_slug}}/config/settings/local.py
@@ -1,4 +1,10 @@
-from .base import * # noqa
+# ruff: noqa: E501
+from .base import * # noqa: F403
+from .base import INSTALLED_APPS
+from .base import MIDDLEWARE
+{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
+from .base import WEBPACK_LOADER
+{%- endif %}
from .base import env
# GENERAL
@@ -11,7 +17,7 @@ SECRET_KEY = env(
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"]
+ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"] # noqa: S104
# CACHES
# ------------------------------------------------------------------------------
@@ -20,7 +26,7 @@ CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
"LOCATION": "",
- }
+ },
}
# EMAIL
@@ -37,7 +43,9 @@ EMAIL_HOST = "localhost"
EMAIL_PORT = 1025
{%- else -%}
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
-EMAIL_BACKEND = env("DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend")
+EMAIL_BACKEND = env(
+ "DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend",
+)
{%- endif %}
{%- if cookiecutter.use_whitenoise == 'y' %}
@@ -45,18 +53,23 @@ EMAIL_BACKEND = env("DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.c
# WhiteNoise
# ------------------------------------------------------------------------------
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development
-INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa: F405
+INSTALLED_APPS = ["whitenoise.runserver_nostatic", *INSTALLED_APPS]
{% endif %}
# django-debug-toolbar
# ------------------------------------------------------------------------------
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
-INSTALLED_APPS += ["debug_toolbar"] # noqa: F405
+INSTALLED_APPS += ["debug_toolbar"]
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware
-MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] # noqa: F405
+MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
DEBUG_TOOLBAR_CONFIG = {
- "DISABLE_PANELS": ["debug_toolbar.panels.redirects.RedirectsPanel"],
+ "DISABLE_PANELS": [
+ "debug_toolbar.panels.redirects.RedirectsPanel",
+ # Disable profiling panel due to an issue with Python 3.12:
+ # https://github.com/jazzband/django-debug-toolbar/issues/1875
+ "debug_toolbar.panels.profiling.ProfilingPanel",
+ ],
"SHOW_TEMPLATE_CONTEXT": True,
}
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
@@ -75,12 +88,21 @@ if env("USE_DOCKER") == "yes":
# The node container isn't started (yet?)
pass
{%- endif %}
+ {%- if cookiecutter.windows == 'y' %}
+ # RunServerPlus
+ # ------------------------------------------------------------------------------
+ # This is a custom setting for RunServerPlus to fix reloader issue in Windows docker environment
+ # Werkzeug reloader type [auto, watchdog, or stat]
+ RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
+ # If you have CPU and IO load issues, you can increase this poller interval e.g) 5
+ RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 1
+ {%- endif %}
{%- endif %}
# django-extensions
# ------------------------------------------------------------------------------
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
-INSTALLED_APPS += ["django_extensions"] # noqa: F405
+INSTALLED_APPS += ["django_extensions"]
{% if cookiecutter.use_celery == 'y' -%}
# Celery
@@ -96,7 +118,7 @@ CELERY_TASK_EAGER_PROPAGATES = True
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
# django-webpack-loader
# ------------------------------------------------------------------------------
-WEBPACK_LOADER["DEFAULT"]["CACHE"] = not DEBUG # noqa: F405
+WEBPACK_LOADER["DEFAULT"]["CACHE"] = not DEBUG
{%- endif %}
# Your stuff...
diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py
index 971efa396..a650d8315 100644
--- a/{{cookiecutter.project_slug}}/config/settings/production.py
+++ b/{{cookiecutter.project_slug}}/config/settings/production.py
@@ -1,3 +1,4 @@
+# ruff: noqa: E501
{% if cookiecutter.use_sentry == 'y' -%}
import logging
@@ -12,7 +13,12 @@ from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.redis import RedisIntegration
{% endif -%}
-from .base import * # noqa
+from .base import * # noqa: F403
+from .base import DATABASES
+from .base import INSTALLED_APPS
+{%- if cookiecutter.use_drf == "y" %}
+from .base import SPECTACULAR_SETTINGS
+{%- endif %}
from .base import env
# GENERAL
@@ -24,7 +30,7 @@ ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["{{ cookiecutter.domai
# DATABASES
# ------------------------------------------------------------------------------
-DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60) # noqa: F405
+DATABASES["default"]["CONN_MAX_AGE"] = env.int("CONN_MAX_AGE", default=60)
# CACHES
# ------------------------------------------------------------------------------
@@ -38,7 +44,7 @@ CACHES = {
# https://github.com/jazzband/django-redis#memcached-exceptions-behavior
"IGNORE_EXCEPTIONS": True,
},
- }
+ },
}
# SECURITY
@@ -49,24 +55,34 @@ SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
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-name
+SESSION_COOKIE_NAME = "__Secure-sessionid"
# 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-name
+CSRF_COOKIE_NAME = "__Secure-csrftoken"
# 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)
+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)
+SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
+ "DJANGO_SECURE_CONTENT_TYPE_NOSNIFF",
+ default=True,
+)
{% if cookiecutter.cloud_provider != 'None' -%}
# STORAGES
# ------------------------------------------------------------------------------
# https://django-storages.readthedocs.io/en/latest/#installation
-INSTALLED_APPS += ["storages"] # noqa: F405
+INSTALLED_APPS += ["storages"]
{%- endif -%}
{% if cookiecutter.cloud_provider == 'AWS' %}
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
@@ -103,35 +119,99 @@ AZURE_CONTAINER = env("DJANGO_AZURE_CONTAINER_NAME")
{% endif -%}
{% if cookiecutter.cloud_provider != 'None' or cookiecutter.use_whitenoise == 'y' -%}
-# STATIC
+# STATIC & MEDIA
# ------------------------
-{% endif -%}
-{% if cookiecutter.use_whitenoise == 'y' -%}
-STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
-{% elif cookiecutter.cloud_provider == 'AWS' -%}
-STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticS3Storage"
+STORAGES = {
+{%- if cookiecutter.use_whitenoise == 'y' and cookiecutter.cloud_provider == 'None' %}
+ "default": {
+ "BACKEND": "django.core.files.storage.FileSystemStorage",
+ },
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+{%- elif cookiecutter.cloud_provider == 'AWS' %}
+ "default": {
+ "BACKEND": "storages.backends.s3.S3Storage",
+ "OPTIONS": {
+ "location": "media",
+ "file_overwrite": False,
+ },
+ },
+ {%- if cookiecutter.use_whitenoise == 'y' %}
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+ {%- else %}
+ "staticfiles": {
+ "BACKEND": "storages.backends.s3.S3Storage",
+ "OPTIONS": {
+ "location": "static",
+ "default_acl": "public-read",
+ },
+ },
+ {%- endif %}
+{%- elif cookiecutter.cloud_provider == 'GCP' %}
+ "default": {
+ "BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
+ "OPTIONS": {
+ "location": "media",
+ "file_overwrite": False,
+ },
+ },
+ {%- if cookiecutter.use_whitenoise == 'y' %}
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+ {%- else %}
+ "staticfiles": {
+ "BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
+ "OPTIONS": {
+ "location": "static",
+ "default_acl": "publicRead",
+ },
+ },
+ {%- endif %}
+{%- elif cookiecutter.cloud_provider == 'Azure' %}
+ "default": {
+ "BACKEND": "storages.backends.azure_storage.AzureStorage",
+ "OPTIONS": {
+ "location": "media",
+ "file_overwrite": False,
+ },
+ },
+ {%- if cookiecutter.use_whitenoise == 'y' %}
+ "staticfiles": {
+ "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
+ },
+ {%- else %}
+ "staticfiles": {
+ "BACKEND": "storages.backends.azure_storage.AzureStorage",
+ "OPTIONS": {
+ "location": "static",
+ },
+ },
+ {%- endif %}
+{%- endif %}
+}
+{%- endif %}
+
+{%- if cookiecutter.cloud_provider == 'AWS' %}
+MEDIA_URL = f"https://{aws_s3_domain}/media/"
+{%- if cookiecutter.use_whitenoise == 'n' %}
COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy"
STATIC_URL = f"https://{aws_s3_domain}/static/"
-{% elif cookiecutter.cloud_provider == 'GCP' -%}
-STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticGoogleCloudStorage"
+{%- endif %}
+{%- elif cookiecutter.cloud_provider == 'GCP' %}
+MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/"
+{%- if cookiecutter.use_whitenoise == 'n' %}
COLLECTFAST_STRATEGY = "collectfast.strategies.gcloud.GoogleCloudStrategy"
STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/"
-{% elif cookiecutter.cloud_provider == 'Azure' -%}
-STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticAzureStorage"
-STATIC_URL = f"https://{AZURE_ACCOUNT_NAME}.blob.core.windows.net/static/"
-{% endif -%}
-
-# MEDIA
-# ------------------------------------------------------------------------------
-{%- if cookiecutter.cloud_provider == 'AWS' %}
-DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaS3Storage"
-MEDIA_URL = f"https://{aws_s3_domain}/media/"
-{%- elif cookiecutter.cloud_provider == 'GCP' %}
-DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaGoogleCloudStorage"
-MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/"
+{%- endif %}
{%- elif cookiecutter.cloud_provider == 'Azure' %}
-DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaAzureStorage"
MEDIA_URL = f"https://{AZURE_ACCOUNT_NAME}.blob.core.windows.net/media/"
+{%- if cookiecutter.use_whitenoise == 'n' %}
+STATIC_URL = f"https://{AZURE_ACCOUNT_NAME}.blob.core.windows.net/static/"
+{%- endif %}
{%- endif %}
# EMAIL
@@ -157,7 +237,7 @@ ADMIN_URL = env("DJANGO_ADMIN_URL")
# Anymail
# ------------------------------------------------------------------------------
# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
-INSTALLED_APPS += ["anymail"] # noqa: F405
+INSTALLED_APPS += ["anymail"]
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
# https://anymail.readthedocs.io/en/stable/installation/#anymail-settings-reference
{%- if cookiecutter.mail_service == 'Mailgun' %}
@@ -200,12 +280,12 @@ ANYMAIL = {
"SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
"SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
}
-{%- elif cookiecutter.mail_service == 'SendinBlue' %}
-# https://anymail.readthedocs.io/en/stable/esps/sendinblue/
-EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend"
+{%- elif cookiecutter.mail_service == 'Brevo' %}
+# https://anymail.readthedocs.io/en/stable/esps/brevo/
+EMAIL_BACKEND = "anymail.backends.brevo.EmailBackend"
ANYMAIL = {
- "SENDINBLUE_API_KEY": env("SENDINBLUE_API_KEY"),
- "SENDINBLUE_API_URL": env("SENDINBLUE_API_URL", default="https://api.sendinblue.com/v3/"),
+ "BREVO_API_KEY": env("BREVO_API_KEY"),
+ "BREVO_API_URL": env("BREVO_API_URL", default="https://api.brevo.com/v3/"),
}
{%- elif cookiecutter.mail_service == 'SparkPost' %}
# https://anymail.readthedocs.io/en/stable/esps/sparkpost/
@@ -230,10 +310,11 @@ COMPRESS_ENABLED = env.bool("COMPRESS_ENABLED", default=True)
COMPRESS_STORAGE = "compressor.storage.GzipCompressorFileStorage"
{%- elif cookiecutter.cloud_provider in ('AWS', 'GCP', 'Azure') and cookiecutter.use_whitenoise == 'n' %}
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE
-COMPRESS_STORAGE = STATICFILES_STORAGE
+COMPRESS_STORAGE = STORAGES["staticfiles"]["BACKEND"]
{%- endif %}
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_URL
-COMPRESS_URL = STATIC_URL{% if cookiecutter.use_whitenoise == 'y' or cookiecutter.cloud_provider == 'None' %} # noqa: F405{% endif %}
+COMPRESS_URL = STATIC_URL{% if cookiecutter.use_whitenoise == 'y' or cookiecutter.cloud_provider == 'None' %} # noqa: F405
+{%- endif -%}
{%- if cookiecutter.use_whitenoise == 'y' %}
# https://django-compressor.readthedocs.io/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
COMPRESS_OFFLINE = True # Offline compression is required when using Whitenoise
@@ -251,7 +332,7 @@ COMPRESS_FILTERS = {
# Collectfast
# ------------------------------------------------------------------------------
# https://github.com/antonagestam/collectfast#installation
-INSTALLED_APPS = ["collectfast"] + INSTALLED_APPS # noqa: F405
+INSTALLED_APPS = ["collectfast", *INSTALLED_APPS]
{% endif %}
# LOGGING
# ------------------------------------------------------------------------------
@@ -311,7 +392,7 @@ LOGGING = {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
- }
+ },
},
"root": {"level": "INFO", "handlers": ["console"]},
"loggers": {
@@ -363,7 +444,7 @@ sentry_sdk.init(
# django-rest-framework
# -------------------------------------------------------------------------------
# Tools that generate code samples can use SERVERS to point to the correct domain
-SPECTACULAR_SETTINGS["SERVERS"] = [ # noqa: F405
+SPECTACULAR_SETTINGS["SERVERS"] = [
{"url": "https://{{ cookiecutter.domain_name }}", "description": "Production server"},
]
diff --git a/{{cookiecutter.project_slug}}/config/settings/test.py b/{{cookiecutter.project_slug}}/config/settings/test.py
index 68126182e..696b48710 100644
--- a/{{cookiecutter.project_slug}}/config/settings/test.py
+++ b/{{cookiecutter.project_slug}}/config/settings/test.py
@@ -2,7 +2,8 @@
With these settings, tests run faster.
"""
-from .base import * # noqa
+from .base import * # noqa: F403
+from .base import TEMPLATES
from .base import env
# GENERAL
@@ -27,17 +28,17 @@ EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
# DEBUGGING FOR TEMPLATES
# ------------------------------------------------------------------------------
-TEMPLATES[0]["OPTIONS"]["debug"] = True # type: ignore # noqa: F405
+TEMPLATES[0]["OPTIONS"]["debug"] = True # type: ignore[index]
# MEDIA
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
-MEDIA_URL = 'http://media.testserver'
+MEDIA_URL = "http://media.testserver"
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
# django-webpack-loader
# ------------------------------------------------------------------------------
-WEBPACK_LOADER["DEFAULT"]["LOADER_CLASS"] = "webpack_loader.loader.FakeWebpackLoader" # noqa: F405
+WEBPACK_LOADER["DEFAULT"]["LOADER_CLASS"] = "webpack_loader.loaders.FakeWebpackLoader" # noqa: F405
{%- endif %}
# Your stuff...
diff --git a/{{cookiecutter.project_slug}}/config/urls.py b/{{cookiecutter.project_slug}}/config/urls.py
index 7c5ad1a7e..aca4352e6 100644
--- a/{{cookiecutter.project_slug}}/config/urls.py
+++ b/{{cookiecutter.project_slug}}/config/urls.py
@@ -1,27 +1,37 @@
+# ruff: noqa
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
{%- if cookiecutter.use_async == 'y' %}
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
{%- endif %}
-from django.urls import include, path
+from django.urls import include
+from django.urls import path
from django.views import defaults as default_views
from django.views.generic import TemplateView
{%- if cookiecutter.use_drf == 'y' %}
-from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
+from drf_spectacular.views import SpectacularAPIView
+from drf_spectacular.views import SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token
{%- endif %}
urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
- path("about/", TemplateView.as_view(template_name="pages/about.html"), name="about"),
+ path(
+ "about/",
+ TemplateView.as_view(template_name="pages/about.html"),
+ name="about",
+ ),
# Django Admin, use {% raw %}{% url 'admin:index' %}{% endraw %}
path(settings.ADMIN_URL, admin.site.urls),
# User management
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)
+ # ...
+ # Media files
+ *static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT),
+]
{%- if cookiecutter.use_async == 'y' %}
if settings.DEBUG:
# Static file serving when using Gunicorn + Uvicorn for local web socket development
@@ -33,7 +43,7 @@ urlpatterns += [
# API base url
path("api/", include("config.api_router")),
# DRF auth token
- path("auth-token/", obtain_auth_token),
+ path("api/auth-token/", obtain_auth_token),
path("api/schema/", SpectacularAPIView.as_view(), name="api-schema"),
path(
"api/docs/",
diff --git a/{{cookiecutter.project_slug}}/config/wsgi.py b/{{cookiecutter.project_slug}}/config/wsgi.py
index 3fd809ef3..73a6cddcb 100644
--- a/{{cookiecutter.project_slug}}/config/wsgi.py
+++ b/{{cookiecutter.project_slug}}/config/wsgi.py
@@ -1,3 +1,4 @@
+# ruff: noqa
"""
WSGI config for {{ cookiecutter.project_name }} project.
@@ -13,6 +14,7 @@ middleware here, or combine a Django application with an application of another
framework.
"""
+
import os
import sys
from pathlib import Path
diff --git a/{{cookiecutter.project_slug}}/docker-compose.docs.yml b/{{cookiecutter.project_slug}}/docker-compose.docs.yml
new file mode 100644
index 000000000..215b6c3b7
--- /dev/null
+++ b/{{cookiecutter.project_slug}}/docker-compose.docs.yml
@@ -0,0 +1,16 @@
+services:
+ docs:
+ image: {{ cookiecutter.project_slug }}_local_docs
+ container_name: {{ cookiecutter.project_slug }}_local_docs
+ build:
+ context: .
+ dockerfile: ./compose/local/docs/Dockerfile
+ env_file:
+ - ./.envs/.local/.django
+ volumes:
+ - ./docs:/docs:z
+ - ./config:/app/config:z
+ - ./{{ cookiecutter.project_slug }}:/app/{{ cookiecutter.project_slug }}:z
+ ports:
+ - '9000:9000'
+ command: /start-docs
diff --git a/{{cookiecutter.project_slug}}/local.yml b/{{cookiecutter.project_slug}}/docker-compose.local.yml
similarity index 86%
rename from {{cookiecutter.project_slug}}/local.yml
rename to {{cookiecutter.project_slug}}/docker-compose.local.yml
index 692d87499..eced08ee8 100644
--- a/{{cookiecutter.project_slug}}/local.yml
+++ b/{{cookiecutter.project_slug}}/docker-compose.local.yml
@@ -1,8 +1,7 @@
-version: '3'
-
volumes:
{{ cookiecutter.project_slug }}_local_postgres_data: {}
{{ cookiecutter.project_slug }}_local_postgres_data_backups: {}
+ {% if cookiecutter.use_celery == 'y' %}{{ cookiecutter.project_slug }}_local_redis_data: {}{% endif %}
services:
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
@@ -40,25 +39,10 @@ services:
env_file:
- ./.envs/.local/.postgres
- docs:
- image: {{ cookiecutter.project_slug }}_local_docs
- container_name: {{ cookiecutter.project_slug }}_local_docs
- build:
- context: .
- dockerfile: ./compose/local/docs/Dockerfile
- env_file:
- - ./.envs/.local/.django
- volumes:
- - ./docs:/docs:z
- - ./config:/app/config:z
- - ./{{ cookiecutter.project_slug }}:/app/{{ cookiecutter.project_slug }}:z
- ports:
- - '9000:9000'
- command: /start-docs
{%- if cookiecutter.use_mailpit == 'y' %}
mailpit:
- image: axllent/mailpit:v1.8
+ image: docker.io/axllent/mailpit:latest
container_name: {{ cookiecutter.project_slug }}_local_mailpit
ports:
- "8025:8025"
@@ -67,8 +51,12 @@ services:
{%- if cookiecutter.use_celery == 'y' %}
redis:
- image: redis:6
+ image: docker.io/redis:6
container_name: {{ cookiecutter.project_slug }}_local_redis
+ {% if cookiecutter.use_celery == 'y' %}
+ volumes:
+ - {{ cookiecutter.project_slug }}_local_redis_data:/data
+ {% endif %}
celeryworker:
<<: *django
diff --git a/{{cookiecutter.project_slug}}/production.yml b/{{cookiecutter.project_slug}}/docker-compose.production.yml
similarity index 91%
rename from {{cookiecutter.project_slug}}/production.yml
rename to {{cookiecutter.project_slug}}/docker-compose.production.yml
index 30d72d61e..d0d06338d 100644
--- a/{{cookiecutter.project_slug}}/production.yml
+++ b/{{cookiecutter.project_slug}}/docker-compose.production.yml
@@ -1,5 +1,3 @@
-version: '3'
-
volumes:
production_postgres_data: {}
production_postgres_data_backups: {}
@@ -7,6 +5,10 @@ volumes:
{%- if cookiecutter.cloud_provider == 'None' %}
production_django_media: {}
{%- endif %}
+ {% if cookiecutter.use_celery == 'y' %}
+ production_redis_data: {}
+ {% endif %}
+
services:
django:{% if cookiecutter.use_celery == 'y' %} &django{% endif %}
@@ -67,7 +69,13 @@ services:
{%- endif %}
redis:
- image: redis:6
+ image: docker.io/redis:6
+ {% if cookiecutter.use_celery == 'y' %}
+ volumes:
+ - production_redis_data:/data
+ {% endif %}
+
+
{%- if cookiecutter.use_celery == 'y' %}
celeryworker:
@@ -102,7 +110,7 @@ services:
build:
context: .
dockerfile: ./compose/production/nginx/Dockerfile
- image: {{ cookiecutter.project_slug }}_local_nginx
+ image: {{ cookiecutter.project_slug }}_production_nginx
depends_on:
- django
volumes:
diff --git a/{{cookiecutter.project_slug}}/docs/conf.py b/{{cookiecutter.project_slug}}/docs/conf.py
index c640e1c63..40d59dbbb 100644
--- a/{{cookiecutter.project_slug}}/docs/conf.py
+++ b/{{cookiecutter.project_slug}}/docs/conf.py
@@ -1,3 +1,4 @@
+# ruff: noqa
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
diff --git a/{{cookiecutter.project_slug}}/docs/howto.rst b/{{cookiecutter.project_slug}}/docs/howto.rst
index 7d86351cf..944c2b731 100644
--- a/{{cookiecutter.project_slug}}/docs/howto.rst
+++ b/{{cookiecutter.project_slug}}/docs/howto.rst
@@ -15,7 +15,7 @@ from inside the `{{cookiecutter.project_slug}}/docs` directory.
{% else %}
To build and serve docs, use the commands::
- docker compose -f local.yml up docs
+ docker compose -f docker-compose.local.yml up docs
{% endif %}
@@ -26,7 +26,7 @@ Changes to files in `docs/_source` will be picked up and reloaded automatically.
Docstrings to Documentation
----------------------------------------------------------------------
-The sphinx extension `apidoc `_ is used to automatically document code using signatures and docstrings.
+The sphinx extension `apidoc `_ is used to automatically document code using signatures and docstrings.
Numpy or Google style docstrings will be picked up from project files and available for documentation. See the `Napoleon `_ extension for details.
diff --git a/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst b/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst
index d8e769167..148854c64 100644
--- a/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst
+++ b/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst
@@ -21,7 +21,7 @@ Next, you have to add new remote python interpreter, based on already tested dep
.. image:: images/3.png
-Switch to *Docker Compose* and select `local.yml` file from directory of your project, next set *Service name* to `django`
+Switch to *Docker Compose* and select `docker-compose.local.yml` file from directory of your project, next set *Service name* to `django`
.. image:: images/4.png
diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js
index df434c134..ee6e70282 100644
--- a/{{cookiecutter.project_slug}}/gulpfile.js
+++ b/{{cookiecutter.project_slug}}/gulpfile.js
@@ -106,7 +106,7 @@ function imgCompression() {
function asyncRunServer() {
const cmd = spawn(
'gunicorn',
- ['config.asgi', '-k', 'uvicorn.workers.UvicornWorker', '--reload'],
+ ['config.asgi', '-k', 'uvicorn_worker.UvicornWorker', '--reload'],
{stdio: 'inherit'},
);
cmd.on('close', function (code) {
diff --git a/{{cookiecutter.project_slug}}/locale/README.md b/{{cookiecutter.project_slug}}/locale/README.md
index a514ad10c..8971441a0 100644
--- a/{{cookiecutter.project_slug}}/locale/README.md
+++ b/{{cookiecutter.project_slug}}/locale/README.md
@@ -3,7 +3,7 @@
Start by configuring the `LANGUAGES` settings in `base.py`, by uncommenting languages you are willing to support. Then, translations strings will be placed in this folder when running:
```bash
-{% if cookiecutter.use_docker == 'y' %}docker compose -f local.yml run --rm django {% endif %}python manage.py makemessages -all --no-location
+{% if cookiecutter.use_docker == 'y' %}docker compose -f docker-compose.local.yml run --rm django {% endif %}python manage.py makemessages -all --no-location
```
This should generate `django.po` (stands for Portable Object) files under each locale `/LC_MESSAGES/django.po`. Each translatable string in the codebase is collected with its `msgid` and need to be translated as `msgstr`, for example:
@@ -16,7 +16,7 @@ msgstr "utilisateurs"
Once all translations are done, they need to be compiled into `.mo` files (stands for Machine Object), which are the actual binary files used by the application:
```bash
-{% if cookiecutter.use_docker == 'y' %}docker compose -f local.yml run --rm django {% endif %}python manage.py compilemessages
+{% if cookiecutter.use_docker == 'y' %}docker compose -f docker-compose.local.yml run --rm django {% endif %}python manage.py compilemessages
```
Note that the `.po` files are NOT used by the application directly, so if the `.mo` files are out of dates, the content won't appear as translated even if the `.po` files are up-to-date.
diff --git a/{{cookiecutter.project_slug}}/manage.py b/{{cookiecutter.project_slug}}/manage.py
index c44cc826d..a39871814 100755
--- a/{{cookiecutter.project_slug}}/manage.py
+++ b/{{cookiecutter.project_slug}}/manage.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# ruff: noqa
import os
import sys
from pathlib import Path
@@ -13,7 +14,7 @@ if __name__ == "__main__":
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
- import django # noqa
+ import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
diff --git a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py
index 35139fb2e..c83ed7166 100644
--- a/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py
+++ b/{{cookiecutter.project_slug}}/merge_production_dotenvs_in_dotenv.py
@@ -1,3 +1,4 @@
+# ruff: noqa
import os
from collections.abc import Sequence
from pathlib import Path
diff --git a/{{cookiecutter.project_slug}}/package.json b/{{cookiecutter.project_slug}}/package.json
index 99b984da6..0b17e5e0b 100644
--- a/{{cookiecutter.project_slug}}/package.json
+++ b/{{cookiecutter.project_slug}}/package.json
@@ -8,15 +8,15 @@
"autoprefixer": "^10.4.0",
"babel-loader": "^9.1.2",
"bootstrap": "^5.2.3",
- "browser-sync": "^2.27.7",
+ "browser-sync": "^3.0.2",
"css-loader": "^6.5.1",
"gulp-concat": "^2.6.1",
"concurrently": "^8.0.1",
- "cssnano": "^6.0.0",
+ "cssnano": "^7.0.0",
"gulp": "^4.0.2",
"gulp-imagemin": "^7.1.0",
"gulp-plumber": "^1.2.1",
- "gulp-postcss": "^9.0.1",
+ "gulp-postcss": "^10.0.0",
"gulp-rename": "^2.0.0",
"gulp-sass": "^5.0.0",
"gulp-uglify-es": "^3.0.0",
@@ -24,18 +24,18 @@
"node-sass-tilde-importer": "^1.0.2",
"pixrem": "^5.0.0",
"postcss": "^8.3.11",
- "postcss-loader": "^7.0.2",
+ "postcss-loader": "^8.0.0",
"postcss-preset-env": "^9.0.0",
"sass": "^1.43.4",
- "sass-loader": "^13.2.0",
+ "sass-loader": "^14.0.0",
"webpack": "^5.65.0",
- "webpack-bundle-tracker": "^2.0.0",
+ "webpack-bundle-tracker": "^3.0.1",
"webpack-cli": "^5.0.1",
- "webpack-dev-server": "^4.6.0",
+ "webpack-dev-server": "^5.0.2",
"webpack-merge": "^5.8.0"
},
"engines": {
- "node": "18"
+ "node": "20"
},
"browserslist": [
"last 2 versions"
diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml
index 7e4c9aa9c..31e290dff 100644
--- a/{{cookiecutter.project_slug}}/pyproject.toml
+++ b/{{cookiecutter.project_slug}}/pyproject.toml
@@ -1,7 +1,7 @@
# ==== pytest ====
[tool.pytest.ini_options]
minversion = "6.0"
-addopts = "--ds=config.settings.test --reuse-db"
+addopts = "--ds=config.settings.test --reuse-db --import-mode=importlib"
python_files = [
"tests.py",
"test_*.py",
@@ -16,28 +16,9 @@ include = ["{{cookiecutter.project_slug}}/**"]
omit = ["*/migrations/*", "*/tests/*"]
plugins = ["django_coverage_plugin"]
-
-# ==== black ====
-[tool.black]
-line-length = 119
-target-version = ['py311']
-
-
-# ==== isort ====
-[tool.isort]
-profile = "black"
-line_length = 119
-known_first_party = [
- "{{cookiecutter.project_slug}}",
- "config",
-]
-skip = ["venv/"]
-skip_glob = ["**/migrations/*.py"]
-
-
# ==== mypy ====
[tool.mypy]
-python_version = "3.11"
+python_version = "3.12"
check_untyped_defs = true
ignore_missing_imports = true
warn_unused_ignores = true
@@ -58,47 +39,13 @@ ignore_errors = true
[tool.django-stubs]
django_settings_module = "config.settings.test"
-
-# ==== PyLint ====
-[tool.pylint.MASTER]
-load-plugins = [
- "pylint_django",
-{%- if cookiecutter.use_celery == "y" %}
- "pylint_celery",
-{%- endif %}
-]
-django-settings-module = "config.settings.local"
-
-[tool.pylint.FORMAT]
-max-line-length = 119
-
-[tool.pylint."MESSAGES CONTROL"]
-disable = [
- "missing-docstring",
- "invalid-name",
-]
-
-[tool.pylint.DESIGN]
-max-parents = 13
-
-[tool.pylint.TYPECHECK]
-generated-members = [
- "REQUEST",
- "acl_users",
- "aq_parent",
- "[a-zA-Z]+_set{1,2}",
- "save",
- "delete",
-]
-
-
# ==== djLint ====
[tool.djlint]
blank_line_after_tag = "load,extends"
close_void_tags = true
format_css = true
format_js = true
-# TODO: remove T002 when fixed https://github.com/Riverside-Healthcare/djLint/issues/687
+# TODO: remove T002 when fixed https://github.com/djlint/djLint/issues/687
ignore = "H006,H030,H031,T002"
include = "H017,H035"
indent = 2
@@ -110,3 +57,121 @@ indent_size = 2
[tool.djlint.js]
indent_size = 2
+
+[tool.ruff]
+# Exclude a variety of commonly ignored directories.
+exclude = [
+ ".bzr",
+ ".direnv",
+ ".eggs",
+ ".git",
+ ".git-rewrite",
+ ".hg",
+ ".mypy_cache",
+ ".nox",
+ ".pants.d",
+ ".pytype",
+ ".ruff_cache",
+ ".svn",
+ ".tox",
+ ".venv",
+ "__pypackages__",
+ "_build",
+ "buck-out",
+ "build",
+ "dist",
+ "node_modules",
+ "venv",
+ "*/migrations/*.py",
+ "staticfiles/*"
+]
+# Same as Django: https://github.com/cookiecutter/cookiecutter-django/issues/4792.
+line-length = 88
+indent-width = 4
+target-version = "py312"
+
+[tool.ruff.lint]
+select = [
+ "F",
+ "E",
+ "W",
+ "C90",
+ "I",
+ "N",
+ "UP",
+ "YTT",
+ # "ANN", # flake8-annotations: we should support this in the future but 100+ errors atm
+ "ASYNC",
+ "S",
+ "BLE",
+ "FBT",
+ "B",
+ "A",
+ "COM",
+ "C4",
+ "DTZ",
+ "T10",
+ "DJ",
+ "EM",
+ "EXE",
+ "FA",
+ 'ISC',
+ "ICN",
+ "G",
+ 'INP',
+ 'PIE',
+ "T20",
+ 'PYI',
+ 'PT',
+ "Q",
+ "RSE",
+ "RET",
+ "SLF",
+ "SLOT",
+ "SIM",
+ "TID",
+ "TCH",
+ "INT",
+ # "ARG", # Unused function argument
+ "PTH",
+ "ERA",
+ "PD",
+ "PGH",
+ "PL",
+ "TRY",
+ "FLY",
+ # "NPY",
+ # "AIR",
+ "PERF",
+ # "FURB",
+ # "LOG",
+ "RUF"
+]
+ignore = [
+ "S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/
+ "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
+ "SIM102", # sometimes it's better to nest
+ "UP038" # Checks for uses of isinstance/issubclass that take a tuple
+ # of types for comparison.
+ # Deactivated because it can make the code slow:
+ # https://github.com/astral-sh/ruff/issues/7871
+]
+# Allow fix for all enabled rules (when `--fix`) is provided.
+fixable = ["ALL"]
+unfixable = []
+# The fixes in extend-unsafe-fixes will require
+# provide the `--unsafe-fixes` flag when fixing.
+extend-unsafe-fixes = [
+ "UP038"
+]
+# Allow unused variables when underscore-prefixed.
+dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
+
+[tool.ruff.format]
+quote-style = "double"
+indent-style = "space"
+skip-magic-trailing-comma = false
+line-ending = "auto"
+
+[tool.ruff.lint.isort]
+force-single-line = true
diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt
index 5cbeb2597..f27e6df5f 100644
--- a/{{cookiecutter.project_slug}}/requirements/base.txt
+++ b/{{cookiecutter.project_slug}}/requirements/base.txt
@@ -1,5 +1,5 @@
-python-slugify==8.0.1 # https://github.com/un33k/python-slugify
-Pillow==10.0.1 # https://github.com/python-pillow/Pillow
+python-slugify==8.0.4 # https://github.com/un33k/python-slugify
+Pillow==10.3.0 # https://github.com/python-pillow/Pillow
{%- if cookiecutter.frontend_pipeline == 'Django Compressor' %}
{%- if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %}
rcssmin==1.1.2 --install-option="--without-c-extensions" # https://github.com/ndparker/rcssmin
@@ -9,42 +9,43 @@ rcssmin==1.1.2 # https://github.com/ndparker/rcssmin
{%- endif %}
argon2-cffi==23.1.0 # https://github.com/hynek/argon2_cffi
{%- if cookiecutter.use_whitenoise == 'y' %}
-whitenoise==6.5.0 # https://github.com/evansd/whitenoise
+whitenoise==6.6.0 # https://github.com/evansd/whitenoise
{%- endif %}
-redis==5.0.1 # https://github.com/redis/redis-py
+redis==5.0.6 # https://github.com/redis/redis-py
{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %}
-hiredis==2.2.3 # https://github.com/redis/hiredis-py
+hiredis==2.3.2 # https://github.com/redis/hiredis-py
{%- endif %}
{%- if cookiecutter.use_celery == "y" %}
-celery==5.3.4 # pyup: < 6.0 # https://github.com/celery/celery
-django-celery-beat==2.5.0 # https://github.com/celery/django-celery-beat
+celery==5.4.0 # pyup: < 6.0 # https://github.com/celery/celery
+django-celery-beat==2.6.0 # https://github.com/celery/django-celery-beat
{%- if cookiecutter.use_docker == 'y' %}
flower==2.0.1 # https://github.com/mher/flower
{%- endif %}
{%- endif %}
{%- if cookiecutter.use_async == 'y' %}
-uvicorn[standard]==0.23.2 # https://github.com/encode/uvicorn
+uvicorn[standard]==0.30.1 # https://github.com/encode/uvicorn
+uvicorn-worker==0.2.0 # https://github.com/Kludex/uvicorn-worker
{%- endif %}
# Django
# ------------------------------------------------------------------------------
-django==4.2.5 # pyup: < 5.0 # https://www.djangoproject.com/
+django==4.2.13 # pyup: < 5.0 # https://www.djangoproject.com/
django-environ==0.11.2 # https://github.com/joke2k/django-environ
-django-model-utils==4.3.1 # https://github.com/jazzband/django-model-utils
-django-allauth==0.57.0 # https://github.com/pennersr/django-allauth
-django-crispy-forms==2.0 # https://github.com/django-crispy-forms/django-crispy-forms
-crispy-bootstrap5==0.7 # https://github.com/django-crispy-forms/crispy-bootstrap5
+django-model-utils==4.5.1 # https://github.com/jazzband/django-model-utils
+django-allauth[mfa]==0.63.3 # https://github.com/pennersr/django-allauth
+django-crispy-forms==2.2 # https://github.com/django-crispy-forms/django-crispy-forms
+crispy-bootstrap5==2024.2 # https://github.com/django-crispy-forms/crispy-bootstrap5
{%- if cookiecutter.frontend_pipeline == 'Django Compressor' %}
django-compressor==4.4 # https://github.com/django-compressor/django-compressor
{%- endif %}
-django-redis==5.3.0 # https://github.com/jazzband/django-redis
+django-redis==5.4.0 # https://github.com/jazzband/django-redis
{%- if cookiecutter.use_drf == 'y' %}
# Django REST Framework
-djangorestframework==3.14.0 # https://github.com/encode/django-rest-framework
-django-cors-headers==4.2.0 # https://github.com/adamchainz/django-cors-headers
+djangorestframework==3.15.1 # https://github.com/encode/django-rest-framework
+django-cors-headers==4.3.1 # https://github.com/adamchainz/django-cors-headers
# DRF-spectacular for api documentation
-drf-spectacular==0.26.5 # https://github.com/tfranzel/drf-spectacular
+drf-spectacular==0.27.2 # https://github.com/tfranzel/drf-spectacular
{%- endif %}
{%- if cookiecutter.frontend_pipeline == 'Webpack' %}
-django-webpack-loader==2.0.1 # https://github.com/django-webpack/django-webpack-loader
+django-webpack-loader==3.1.0 # https://github.com/django-webpack/django-webpack-loader
{%- endif %}
diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt
index d31a0345f..96814cd31 100644
--- a/{{cookiecutter.project_slug}}/requirements/local.txt
+++ b/{{cookiecutter.project_slug}}/requirements/local.txt
@@ -1,49 +1,43 @@
--r base.txt
+-r production.txt
-Werkzeug[watchdog]==2.3.7 # https://github.com/pallets/werkzeug
+Werkzeug[watchdog]==3.0.3 # https://github.com/pallets/werkzeug
ipdb==0.13.13 # https://github.com/gotcha/ipdb
{%- if cookiecutter.use_docker == 'y' %}
-psycopg[c]==3.1.12 # https://github.com/psycopg/psycopg
+psycopg[c]==3.1.19 # https://github.com/psycopg/psycopg
{%- else %}
-psycopg[binary]==3.1.12 # https://github.com/psycopg/psycopg
+psycopg[binary]==3.1.19 # https://github.com/psycopg/psycopg
{%- endif %}
{%- if cookiecutter.use_async == 'y' or cookiecutter.use_celery == 'y' %}
-watchfiles==0.20.0 # https://github.com/samuelcolvin/watchfiles
+watchfiles==0.22.0 # https://github.com/samuelcolvin/watchfiles
{%- endif %}
# Testing
# ------------------------------------------------------------------------------
-mypy==1.4.1 # https://github.com/python/mypy
-django-stubs[compatible-mypy]==4.2.3 # https://github.com/typeddjango/django-stubs
-pytest==7.4.2 # https://github.com/pytest-dev/pytest
-pytest-sugar==0.9.7 # https://github.com/Frozenball/pytest-sugar
+mypy==1.10.0 # https://github.com/python/mypy
+django-stubs[compatible-mypy]==5.0.2 # https://github.com/typeddjango/django-stubs
+pytest==8.2.2 # https://github.com/pytest-dev/pytest
+pytest-sugar==1.0.0 # https://github.com/Frozenball/pytest-sugar
{%- if cookiecutter.use_drf == "y" %}
-djangorestframework-stubs[compatible-mypy]==3.14.2 # https://github.com/typeddjango/djangorestframework-stubs
+djangorestframework-stubs[compatible-mypy]==3.15.0 # https://github.com/typeddjango/djangorestframework-stubs
{%- endif %}
# Documentation
# ------------------------------------------------------------------------------
-sphinx==7.2.6 # https://github.com/sphinx-doc/sphinx
-sphinx-autobuild==2021.3.14 # https://github.com/GaretJax/sphinx-autobuild
+sphinx==7.3.7 # https://github.com/sphinx-doc/sphinx
+sphinx-autobuild==2024.4.16 # https://github.com/GaretJax/sphinx-autobuild
# Code quality
# ------------------------------------------------------------------------------
-flake8==6.1.0 # https://github.com/PyCQA/flake8
-flake8-isort==6.1.0 # https://github.com/gforcada/flake8-isort
-coverage==7.3.1 # https://github.com/nedbat/coveragepy
-black==23.9.1 # https://github.com/psf/black
-djlint==1.34.0 # https://github.com/Riverside-Healthcare/djLint
-pylint-django==2.5.3 # https://github.com/PyCQA/pylint-django
-{%- if cookiecutter.use_celery == 'y' %}
-pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery
-{%- endif %}
-pre-commit==3.4.0 # https://github.com/pre-commit/pre-commit
+ruff==0.4.9 # https://github.com/astral-sh/ruff
+coverage==7.5.3 # https://github.com/nedbat/coveragepy
+djlint==1.34.1 # https://github.com/Riverside-Healthcare/djLint
+pre-commit==3.7.1 # https://github.com/pre-commit/pre-commit
# Django
# ------------------------------------------------------------------------------
factory-boy==3.3.0 # https://github.com/FactoryBoy/factory_boy
-django-debug-toolbar==4.2.0 # https://github.com/jazzband/django-debug-toolbar
+django-debug-toolbar==4.4.2 # https://github.com/jazzband/django-debug-toolbar
django-extensions==3.2.3 # https://github.com/django-extensions/django-extensions
django-coverage-plugin==3.1.0 # https://github.com/nedbat/django_coverage_plugin
-pytest-django==4.5.2 # https://github.com/pytest-dev/pytest-django
+pytest-django==4.8.0 # https://github.com/pytest-dev/pytest-django
diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt
index ba6b42e36..9a742a16a 100644
--- a/{{cookiecutter.project_slug}}/requirements/production.txt
+++ b/{{cookiecutter.project_slug}}/requirements/production.txt
@@ -2,43 +2,43 @@
-r base.txt
-gunicorn==21.2.0 # https://github.com/benoitc/gunicorn
-psycopg[c]==3.1.12 # https://github.com/psycopg/psycopg
+gunicorn==22.0.0 # https://github.com/benoitc/gunicorn
+psycopg[c]==3.1.19 # https://github.com/psycopg/psycopg
{%- if cookiecutter.use_whitenoise == 'n' %}
Collectfast==2.2.0 # https://github.com/antonagestam/collectfast
{%- endif %}
{%- if cookiecutter.use_sentry == "y" %}
-sentry-sdk==1.31.0 # https://github.com/getsentry/sentry-python
+sentry-sdk==2.5.1 # https://github.com/getsentry/sentry-python
{%- endif %}
{%- if cookiecutter.use_docker == "n" and cookiecutter.windows == "y" %}
-hiredis==2.2.3 # https://github.com/redis/hiredis-py
+hiredis==2.3.2 # https://github.com/redis/hiredis-py
{%- endif %}
# Django
# ------------------------------------------------------------------------------
{%- if cookiecutter.cloud_provider == 'AWS' %}
-django-storages[s3]==1.14.1 # https://github.com/jschneier/django-storages
+django-storages[s3]==1.14.3 # https://github.com/jschneier/django-storages
{%- elif cookiecutter.cloud_provider == 'GCP' %}
-django-storages[google]==1.14.1 # https://github.com/jschneier/django-storages
+django-storages[google]==1.14.3 # https://github.com/jschneier/django-storages
{%- elif cookiecutter.cloud_provider == 'Azure' %}
-django-storages[azure]==1.14.1 # https://github.com/jschneier/django-storages
+django-storages[azure]==1.14.3 # https://github.com/jschneier/django-storages
{%- endif %}
{%- if cookiecutter.mail_service == 'Mailgun' %}
-django-anymail[mailgun]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[mailgun]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'Amazon SES' %}
-django-anymail[amazon-ses]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[amazon-ses]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'Mailjet' %}
-django-anymail[mailjet]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[mailjet]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'Mandrill' %}
-django-anymail[mandrill]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[mandrill]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'Postmark' %}
-django-anymail[postmark]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[postmark]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'Sendgrid' %}
-django-anymail[sendgrid]==10.1 # https://github.com/anymail/django-anymail
-{%- elif cookiecutter.mail_service == 'SendinBlue' %}
-django-anymail[sendinblue]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[sendgrid]==10.3 # https://github.com/anymail/django-anymail
+{%- elif cookiecutter.mail_service == 'Brevo' %}
+django-anymail[brevo]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'SparkPost' %}
-django-anymail[sparkpost]==10.1 # https://github.com/anymail/django-anymail
+django-anymail[sparkpost]==10.3 # https://github.com/anymail/django-anymail
{%- elif cookiecutter.mail_service == 'Other SMTP' %}
-django-anymail==10.1 # https://github.com/anymail/django-anymail
+django-anymail==10.3 # https://github.com/anymail/django-anymail
{%- endif %}
diff --git a/{{cookiecutter.project_slug}}/runtime.txt b/{{cookiecutter.project_slug}}/runtime.txt
index 76b6e496e..4ddc7cd66 100644
--- a/{{cookiecutter.project_slug}}/runtime.txt
+++ b/{{cookiecutter.project_slug}}/runtime.txt
@@ -1 +1 @@
-python-3.11.6
+python-3.12.3
diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg
deleted file mode 100644
index 2412f1746..000000000
--- a/{{cookiecutter.project_slug}}/setup.cfg
+++ /dev/null
@@ -1,11 +0,0 @@
-# flake8 and pycodestyle don't support pyproject.toml
-# https://github.com/PyCQA/flake8/issues/234
-# https://github.com/PyCQA/pycodestyle/issues/813
-[flake8]
-max-line-length = 119
-exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,.venv
-extend-ignore = E203
-
-[pycodestyle]
-max-line-length = 119
-exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,.venv
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/__init__.py b/{{cookiecutter.project_slug}}/tests/__init__.py
similarity index 100%
rename from {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/utils/__init__.py
rename to {{cookiecutter.project_slug}}/tests/__init__.py
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-bionic.apt b/{{cookiecutter.project_slug}}/utility/requirements-bionic.apt
index 1ca82b264..0e1a6572c 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-bionic.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-bionic.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-bookworm.apt b/{{cookiecutter.project_slug}}/utility/requirements-bookworm.apt
new file mode 100644
index 000000000..f24f6f3da
--- /dev/null
+++ b/{{cookiecutter.project_slug}}/utility/requirements-bookworm.apt
@@ -0,0 +1,23 @@
+##basic build dependencies of various Django apps for Debian Bookworm 12.x
+#build-essential metapackage install: make, gcc, g++,
+build-essential
+#required to translate
+gettext
+python3-dev
+
+##shared dependencies of:
+##Pillow, pylibmc
+zlib1g-dev
+
+##Postgresql and psycopg dependencies
+libpq-dev
+
+##Pillow dependencies
+libtiff5-dev
+libjpeg62-turbo-dev
+libfreetype6-dev
+liblcms2-dev
+libwebp-dev
+
+##django-extensions
+libgraphviz-dev
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-bullseye.apt b/{{cookiecutter.project_slug}}/utility/requirements-bullseye.apt
index 60f602873..e8e36b631 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-bullseye.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-bullseye.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-buster.apt b/{{cookiecutter.project_slug}}/utility/requirements-buster.apt
index 75957f40d..f2c81962d 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-buster.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-buster.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-focal.apt b/{{cookiecutter.project_slug}}/utility/requirements-focal.apt
index fe6f21e46..f400b4196 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-focal.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-focal.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-jammy.apt b/{{cookiecutter.project_slug}}/utility/requirements-jammy.apt
index 63d1587e6..ea52472a1 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-jammy.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-jammy.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt b/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt
index 5c49365ba..ebf0e583e 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-jessie.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-stretch.apt b/{{cookiecutter.project_slug}}/utility/requirements-stretch.apt
index a2b3a7e5e..979eca313 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-stretch.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-stretch.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-trusty.apt b/{{cookiecutter.project_slug}}/utility/requirements-trusty.apt
index 455f1a868..954f78375 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-trusty.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-trusty.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt b/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt
index ba84ef167..1784e40c6 100644
--- a/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt
+++ b/{{cookiecutter.project_slug}}/utility/requirements-xenial.apt
@@ -9,7 +9,7 @@ python3-dev
##Pillow, pylibmc
zlib1g-dev
-##Postgresql and psycopg2 dependencies
+##Postgresql and psycopg dependencies
libpq-dev
##Pillow dependencies
diff --git a/{{cookiecutter.project_slug}}/webpack/dev.config.js b/{{cookiecutter.project_slug}}/webpack/dev.config.js
index c2f14abb1..7c774185e 100644
--- a/{{cookiecutter.project_slug}}/webpack/dev.config.js
+++ b/{{cookiecutter.project_slug}}/webpack/dev.config.js
@@ -6,12 +6,22 @@ module.exports = merge(commonConfig, {
devtool: 'inline-source-map',
devServer: {
port: 3000,
- proxy: {
- {%- if cookiecutter.use_docker == 'n' %}
- '/': 'http://0.0.0.0:8000',
- {%- else %}
- '/': 'http://django:8000',
- {%- endif %}
+ proxy: [
+ {
+ context: ['/'],
+ {%- if cookiecutter.use_docker == 'n' %}
+ target: 'http://0.0.0.0:8000',
+ {%- else %}
+ target: 'http://django:8000',
+ {%- endif %}
+ },
+ ],
+ client: {
+ overlay: {
+ errors: true,
+ warnings: false,
+ runtimeErrors: true,
+ },
},
// We need hot=false (Disable HMR) to set liveReload=true
hot: false,
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py
index 150a914ee..fb6532709 100644
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py
@@ -1,2 +1,5 @@
__version__ = "{{ cookiecutter.version }}"
-__version_info__ = tuple(int(num) if num.isdigit() else num for num in __version__.replace("-", ".", 1).split("."))
+__version_info__ = tuple(
+ int(num) if num.isdigit() else num
+ for num in __version__.replace("-", ".", 1).split(".")
+)
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py
index 7095a4714..98efcd75e 100644
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/conftest.py
@@ -5,10 +5,10 @@ from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory
@pytest.fixture(autouse=True)
-def media_storage(settings, tmpdir):
+def _media_storage(settings, tmpdir) -> None:
settings.MEDIA_ROOT = tmpdir.strpath
-@pytest.fixture
+@pytest.fixture()
def user(db) -> User:
return UserFactory()
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0001_initial.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0001_initial.py
index 304cd6d7c..fd76afb25 100644
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0001_initial.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0001_initial.py
@@ -1,6 +1,7 @@
import django.contrib.sites.models
from django.contrib.sites.models import _simple_domain_name_validator
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
@@ -38,5 +39,5 @@ class Migration(migrations.Migration):
},
bases=(models.Model,),
managers=[("objects", django.contrib.sites.models.SiteManager())],
- )
+ ),
]
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0002_alter_domain_unique.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0002_alter_domain_unique.py
index 2c8d6dac0..4a44a6a92 100644
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0002_alter_domain_unique.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0002_alter_domain_unique.py
@@ -1,5 +1,6 @@
import django.contrib.sites.models
-from django.db import migrations, models
+from django.db import migrations
+from django.db import models
class Migration(migrations.Migration):
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0003_set_site_domain_and_name.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0003_set_site_domain_and_name.py
index e1822375b..85ee2d9c1 100644
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0003_set_site_domain_and_name.py
+++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/contrib/sites/migrations/0003_set_site_domain_and_name.py
@@ -23,7 +23,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
# site is created.
# To avoid this, we need to manually update DB sequence and make sure it's
# greater than the maximum value.
- max_id = site_model.objects.order_by('-id').first().id
+ max_id = site_model.objects.order_by("-id").first().id
with connection.cursor() as cursor:
cursor.execute("SELECT last_value from django_site_id_seq")
(current_id,) = cursor.fetchone()
diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/account_inactive.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/account_inactive.html
deleted file mode 100644
index a9112cf09..000000000
--- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/account/account_inactive.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{% raw %}{% extends "account/base.html" %}
-
-{% load i18n %}
-
-{% block head_title %}
- {% translate "Account Inactive" %}
-{% endblock head_title %}
-{% block inner %}
-
{% translate "The following e-mail addresses are associated with your account:" %}
-
- {% else %}
-
- {% translate "Warning:" %} {% translate "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}
-
- {% if confirmation %}
- {% user_display confirmation.email_address.user as user_display %}
-
- {% blocktranslate with confirmation.email_address.email as email %}Please confirm that {{ email }} is an e-mail address for user {{ user_display }}.{% endblocktranslate %}
-
- {% get_providers as socialaccount_providers %}
- {% if socialaccount_providers %}
-
- {% translate "Please sign in with one of your existing third party accounts:" %}
- {% if ACCOUNT_ALLOW_REGISTRATION %}
- {% blocktranslate trimmed %}
- Or, sign up
- for a {{ site_name }} account and sign in below:
- {% endblocktranslate %}
- {% endif %}
-
-
-
- {% include "socialaccount/snippets/provider_list.html" with process="login" %}
-
-
{% translate "or" %}
-
- {% include "socialaccount/snippets/login_extra.html" %}
- {% else %}
- {% if ACCOUNT_ALLOW_REGISTRATION %}
-
- {% blocktranslate trimmed %}
- If you have not created an account yet, then please
- sign up first.
- {% endblocktranslate %}
-
- {% if token_fail %}
- {% url 'account_reset_password' as passwd_reset_url %}
-
- {% blocktranslate %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktranslate %}
-
- {% blocktranslate %}We have sent an e-mail to you for verification. Follow the link provided to finalize the signup process. Please contact us if you do not receive it within a few minutes.{% endblocktranslate %}
-
- {% blocktranslate %}This part of the site requires us to verify that
-you are who you claim to be. For this purpose, we require that you
-verify ownership of your e-mail address. {% endblocktranslate %}
-
-
- {% blocktranslate %}We have sent an e-mail to you for
-verification. Please click on the link inside this e-mail. Please
-contact us if you do not receive it within a few minutes.{% endblocktranslate %}
-