Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from cookiecutter:master #889

Merged
merged 10 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1653,5 +1653,10 @@
"name": "Francisco Navarro Morales ",
"github_login": "spothound",
"twitter_username": ""
},
{
"name": "Mariot Tsitoara",
"github_login": "mariot",
"twitter_username": ""
}
]
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
POSTGRES_PASSWORD: postgres

env:
CELERY_BROKER_URL: "redis://localhost:6379/0"
REDIS_URL: "redis://localhost:6379/0"
# postgres://user:password@host:port/database
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres"

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
args: ["--tab-width", "2"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py312-plus]
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ All enhancements and patches to Cookiecutter Django will be documented in this f

<!-- GENERATOR_PLACEHOLDER -->

## 2024.10.22


### Changed

- Fix broken links in generated README ([#5482](https://github.com/cookiecutter/cookiecutter-django/pull/5482))

### Updated

- Auto-update pre-commit hooks ([#5483](https://github.com/cookiecutter/cookiecutter-django/pull/5483))

## 2024.10.21


### Changed

- Remove CELERY_BROKER_URL in favor of REDIS_URL ([#4861](https://github.com/cookiecutter/cookiecutter-django/pull/4861))

### Fixed

- Fix a number of issues with Azure storage ([#5476](https://github.com/cookiecutter/cookiecutter-django/pull/5476))

### Updated

- Update coverage to 7.6.4 ([#5480](https://github.com/cookiecutter/cookiecutter-django/pull/5480))

## 2024.10.17


Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,13 @@ Listed in alphabetical order.
</td>
<td></td>
</tr>
<tr>
<td>Mariot Tsitoara</td>
<td>
<a href="https://github.com/mariot">mariot</a>
</td>
<td></td>
</tr>
<tr>
<td>Marlon Castillo</td>
<td>
Expand Down
1 change: 0 additions & 1 deletion docs/1-getting-started/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ The following table lists settings and their defaults for third-party applicatio
======================================= =========================== ============================================== ======================================================================
Environment Variable Django Setting Development Default Production Default
======================================= =========================== ============================================== ======================================================================
CELERY_BROKER_URL CELERY_BROKER_URL auto w/ Docker; raises error w/o raises error
DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a raises error
DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error
DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error
Expand Down
2 changes: 0 additions & 2 deletions docs/2-local-development/developing-locally.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ First things first.
#. Set the environment variables for your database(s): ::

$ export DATABASE_URL=postgres://postgres:<password>@127.0.0.1:5432/<DB name given to createdb>
# Optional: set broker URL if using Celery
$ export CELERY_BROKER_URL=redis://localhost:6379/0

.. note::

Expand Down
2 changes: 0 additions & 2 deletions docs/3-deployment/deployment-on-heroku.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ it's in the ``Procfile``, but is turned off by default:

.. code-block:: bash

# Set the broker URL to Redis
heroku config:set CELERY_BROKER_URL=`heroku config:get REDIS_URL`
# Scale dyno to 1 instance
heroku ps:scale worker=1

Expand Down
6 changes: 6 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def remove_docker_files():
os.remove(os.path.join(".idea", "runConfigurations", file_name))


def remove_nginx_docker_files():
shutil.rmtree(os.path.join("compose", "production", "nginx"))


def remove_utility_files():
shutil.rmtree("utility")

Expand Down Expand Up @@ -457,6 +461,8 @@ def main():

if "{{ cookiecutter.use_docker }}".lower() == "y":
remove_utility_files()
if "{{ cookiecutter.cloud_provider }}".lower() != "none":
remove_nginx_docker_files()
else:
remove_docker_files()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cookiecutter-django"
version = "2024.10.17"
version = "2024.10.22"
description = "A Cookiecutter template for creating production-ready Django projects quickly."
readme = "README.md"
keywords = [
Expand Down
1 change: 0 additions & 1 deletion tests/test_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ docker compose -f docker-compose.local.yml run django python manage.py makemessa
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 \
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
CELERY_BROKER_URL: 'redis://redis:6379/0'
REDIS_URL: 'redis://redis:6379/0'
{%- endif %}

steps:
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

env:
{%- if cookiecutter.use_celery == 'y' %}
CELERY_BROKER_URL: 'redis://localhost:6379/0'
REDIS_URL: 'redis://localhost:6379/0'
{%- endif %}
# postgres://user:password@host:port/database
DATABASE_URL: 'postgres://postgres:postgres@localhost:5432/postgres'
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variables:
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
CELERY_BROKER_URL: 'redis://redis:6379/0'
REDIS_URL: 'redis://redis:6379/0'
{%- endif %}

precommit:
Expand Down
10 changes: 5 additions & 5 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ License: {{cookiecutter.open_source_license}}

## Settings

Moved to [settings](http://cookiecutter-django.readthedocs.io/en/latest/settings.html).
Moved to [settings](https://cookiecutter-django.readthedocs.io/en/latest/1-getting-started/settings.html).

## Basic Commands

Expand Down Expand Up @@ -46,7 +46,7 @@ To run the tests, check your test coverage, and generate an HTML coverage report

### Live reloading and Sass CSS compilation

Moved to [Live reloading and SASS compilation](https://cookiecutter-django.readthedocs.io/en/latest/developing-locally.html#sass-compilation-live-reloading).
Moved to [Live reloading and SASS compilation](https://cookiecutter-django.readthedocs.io/en/latest/2-local-development/developing-locally.html#using-webpack-or-gulp).

{%- if cookiecutter.use_celery == "y" %}

Expand Down Expand Up @@ -87,7 +87,7 @@ celery -A config.celery_app worker -B -l info
In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server [Mailpit](https://github.com/axllent/mailpit) with a web interface is available as docker container.

Container mailpit will start automatically when you will run all docker containers.
Please check [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html) for more details how to start all containers.
Please check [cookiecutter-django Docker documentation](https://cookiecutter-django.readthedocs.io/en/latest/2-local-development/developing-locally-docker.html) for more details how to start all containers.

With Mailpit running, to view messages that are sent by your application, open your browser and go to `http://127.0.0.1:8025`
{%- else %}
Expand Down Expand Up @@ -130,14 +130,14 @@ The following details how to deploy this application.

### Heroku

See detailed [cookiecutter-django Heroku documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-on-heroku.html).
See detailed [cookiecutter-django Heroku documentation](https://cookiecutter-django.readthedocs.io/en/latest/3-deployment/deployment-on-heroku.html).

{%- endif %}
{%- if cookiecutter.use_docker.lower() == "y" %}

### Docker

See detailed [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html).
See detailed [cookiecutter-django Docker documentation](https://cookiecutter-django.readthedocs.io/en/latest/3-deployment/deployment-with-docker.html).

{%- endif %}
{%- if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ 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}\""
"-A config.celery_app -b \"${REDIS_URL}\" flower --basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\""
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ RUN chown -R django:django ${APP_HOME}
USER django

RUN DATABASE_URL="" \
{%- if cookiecutter.use_celery == "y" %}
CELERY_BROKER_URL="" \
{%- endif %}
DJANGO_SETTINGS_MODULE="config.settings.test" \
python manage.py compilemessages

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ echo 'Starting flower'

exec celery \
-A config.celery_app \
-b "${CELERY_BROKER_URL}" \
-b "${REDIS_URL}" \
flower \
--basic_auth="${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}"
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ set -o errexit
set -o pipefail
set -o nounset


{% if cookiecutter.use_celery == 'y' %}
# N.B. If only .env files supported variable expansion...
export CELERY_BROKER_URL="${REDIS_URL}"
{% endif %}

if [ -z "${POSTGRES_USER}" ]; then
base_postgres_image_default_user='postgres'
export POSTGRES_USER="${base_postgres_image_default_user}"
Expand Down
6 changes: 4 additions & 2 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,18 @@
"root": {"level": "INFO", "handlers": ["console"]},
}

REDIS_URL = env("REDIS_URL", default="redis://{% if cookiecutter.use_docker == 'y' %}redis{%else%}localhost{% endif %}:6379/0")

{% if cookiecutter.use_celery == 'y' -%}
# Celery
# ------------------------------------------------------------------------------
if USE_TZ:
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-timezone
CELERY_TIMEZONE = TIME_ZONE
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-broker_url
CELERY_BROKER_URL = env("CELERY_BROKER_URL")
CELERY_BROKER_URL = REDIS_URL
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std:setting-result_backend
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
CELERY_RESULT_BACKEND = REDIS_URL
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-extended
CELERY_RESULT_EXTENDED = True
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#result-backend-always-retry
Expand Down
7 changes: 4 additions & 3 deletions {{cookiecutter.project_slug}}/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .base import * # noqa: F403
from .base import DATABASES
from .base import INSTALLED_APPS
from .base import REDIS_URL
{%- if cookiecutter.use_drf == "y" %}
from .base import SPECTACULAR_SETTINGS
{%- endif %}
Expand All @@ -37,7 +38,7 @@
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": env("REDIS_URL"),
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
# Mimicing memcache behavior.
Expand Down Expand Up @@ -170,7 +171,7 @@
"BACKEND": "storages.backends.azure_storage.AzureStorage",
"OPTIONS": {
"location": "media",
"file_overwrite": False,
"overwrite_files": False,
},
},
{%- if cookiecutter.use_whitenoise == 'y' %}
Expand Down Expand Up @@ -323,7 +324,7 @@
"js": ["compressor.filters.jsmin.JSMinFilter"],
}
{% endif %}
{%- if cookiecutter.use_whitenoise == 'n' -%}
{%- if cookiecutter.use_whitenoise == 'n' and cookiecutter.cloud_provider in ('AWS', 'GCP') -%}
# Collectfasta
# ------------------------------------------------------------------------------
# https://github.com/jasongi/collectfasta#installation
Expand Down
3 changes: 0 additions & 3 deletions {{cookiecutter.project_slug}}/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
sys.path.insert(0, os.path.abspath(".."))
{%- endif %}
os.environ["DATABASE_URL"] = "sqlite:///readthedocs.db"
{%- if cookiecutter.use_celery == 'y' %}
os.environ["CELERY_BROKER_URL"] = os.getenv("REDIS_URL", "redis://redis:6379")
{%- endif %}
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
django.setup()

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sphinx-autobuild==2024.10.3 # https://github.com/GaretJax/sphinx-autobuild
# Code quality
# ------------------------------------------------------------------------------
ruff==0.7.0 # https://github.com/astral-sh/ruff
coverage==7.6.3 # https://github.com/nedbat/coveragepy
coverage==7.6.4 # https://github.com/nedbat/coveragepy
djlint==1.35.2 # https://github.com/Riverside-Healthcare/djLint
pre-commit==4.0.1 # https://github.com/pre-commit/pre-commit

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

gunicorn==23.0.0 # https://github.com/benoitc/gunicorn
psycopg[c]==3.2.3 # https://github.com/psycopg/psycopg
{%- if cookiecutter.use_whitenoise == 'n' %}
{%- if cookiecutter.use_whitenoise == 'n'and cookiecutter.cloud_provider in ('AWS', 'GCP') %}
Collectfasta==3.2.0 # https://github.com/jasongi/collectfasta
{%- endif %}
{%- if cookiecutter.use_sentry == "y" %}
Expand Down
Loading