Skip to content

Commit

Permalink
Merge branch 'master' into lint-format-template-with-ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke authored Jan 9, 2025
2 parents 2747e02 + c5b60d2 commit 1e9bed3
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 31 deletions.
10 changes: 10 additions & 0 deletions .github/contributors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,5 +1673,15 @@
"name": "qwerrrqw",
"github_login": "qwerrrqw",
"twitter_username": ""
},
{
"name": "Pulse-Mind",
"github_login": "pulse-mind",
"twitter_username": ""
},
{
"name": "Hana Belay",
"github_login": "earthcomfy",
"twitter_username": ""
}
]
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
exclude: "{{cookiecutter.project_slug}}|.github/contributors.json|CHANGELOG.md|CONTRIBUTORS.md"
default_stages: [pre-commit]
minimum_pre_commit_version: "3.2.0"

default_language_version:
python: python3.12
Expand Down
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,44 @@ All enhancements and patches to Cookiecutter Django will be documented in this f

<!-- GENERATOR_PLACEHOLDER -->

## 2025.01.07


### Fixed

- Set `minimum_pre_commit_version` in pre-commit config ([#5626](https://github.com/cookiecutter/cookiecutter-django/pull/5626))

### Updated

- Bump traefik from 3.2.3 to 3.3.0 ([#5625](https://github.com/cookiecutter/cookiecutter-django/pull/5625))

## 2025.01.06


### Changed

- Add justfile for use with docker ([#5621](https://github.com/cookiecutter/cookiecutter-django/pull/5621))

## 2025.01.04


### Updated

- Update ruff to 0.8.6 ([#5622](https://github.com/cookiecutter/cookiecutter-django/pull/5622))

## 2025.01.02


### Fixed

- Fix logging configuration for Celery tasks ([#5563](https://github.com/cookiecutter/cookiecutter-django/pull/5563))

### Updated

- Update ruff to 0.8.5 ([#5619](https://github.com/cookiecutter/cookiecutter-django/pull/5619))

- Update pillow to 11.1.0 ([#5617](https://github.com/cookiecutter/cookiecutter-django/pull/5617))

## 2024.12.27


Expand Down
14 changes: 14 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,13 @@ Listed in alphabetical order.
</td>
<td></td>
</tr>
<tr>
<td>Hana Belay</td>
<td>
<a href="https://github.com/earthcomfy">earthcomfy</a>
</td>
<td></td>
</tr>
<tr>
<td>Hana Quadara</td>
<td>
Expand Down Expand Up @@ -1888,6 +1895,13 @@ Listed in alphabetical order.
</td>
<td></td>
</tr>
<tr>
<td>Pulse-Mind</td>
<td>
<a href="https://github.com/pulse-mind">pulse-mind</a>
</td>
<td></td>
</tr>
<tr>
<td>quroom</td>
<td>
Expand Down
35 changes: 35 additions & 0 deletions docs/2-local-development/developing-locally-docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,41 @@ The stack comes with a dedicated node service to build the static assets, watch
.. _Sass: https://sass-lang.com/
.. _live reloading: https://browsersync.io


Using Just for Docker Commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We have included a ``justfile`` to simplify the use of frequent Docker commands for local development.

.. warning::
Currently, "Just" does not reliably handle signals or forward them to its subprocesses. As a result,
pressing CTRL+C (or sending other signals like SIGTERM, SIGINT, or SIGHUP) may only interrupt
"Just" itself rather than its subprocesses.
For more information, see `this GitHub issue <https://github.com/casey/just/issues/2473>`_.

First, install Just using one of the methods described in the `official documentation <https://just.systems/man/en/packages.html>`_.

Here are the available commands:

- ``just build``
Builds the Python image using the local Docker Compose file.

- ``just up``
Starts the containers in detached mode and removes orphaned containers.

- ``just down``
Stops the running containers.

- ``just prune``
Stops and removes containers along with their volumes. You can optionally pass an argument with the service name to prune a single container.

- ``just logs``
Shows container logs. You can optionally pass an argument with the service name to view logs for a specific service.

- ``just manage <command>``
Runs Django management commands within the container. Replace ``<command>`` with any valid Django management command, such as ``migrate``, ``createsuperuser``, or ``shell``.


(Optionally) Developing locally with HTTPS
------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def remove_docker_files():
"docker-compose.local.yml",
"docker-compose.production.yml",
".dockerignore",
"justfile",
]
for file_name in file_names:
os.remove(file_name) # noqa: PTH107
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cookiecutter-django"
version = "2024.12.27"
version = "2025.01.07"
description = "A Cookiecutter template for creating production-ready Django projects quickly."
readme = "README.md"
keywords = [
Expand Down Expand Up @@ -43,7 +43,7 @@ dependencies = [
"pytest-xdist==3.6.1",
"pyyaml==6.0.2",
"requests==2.32.3",
"ruff==0.8.4",
"ruff==0.8.6",
"sh==2.1; sys_platform!='win23'",
"tox==4.23.2",
"tox-uv>=1.17",
Expand Down
50 changes: 25 additions & 25 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
exclude: '^docs/|/migrations/|devcontainer.json'
default_stages: [pre-commit]
minimum_pre_commit_version: "3.2.0"

default_language_version:
python: python3.12
Expand Down Expand Up @@ -35,7 +36,7 @@ repos:

# Run the Ruff linter.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
rev: v0.8.6
hooks:
# Linter
- id: ruff
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/traefik:3.2.3
FROM docker.io/traefik:3.3.0
RUN mkdir -p /etc/traefik/acme \
&& touch /etc/traefik/acme/acme.json \
&& chmod 600 /etc/traefik/acme/acme.json
Expand Down
11 changes: 11 additions & 0 deletions {{cookiecutter.project_slug}}/config/celery_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from celery import Celery
from celery.signals import setup_logging

# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
Expand All @@ -13,5 +14,15 @@
# should have a `CELERY_` prefix.
app.config_from_object("django.conf:settings", namespace="CELERY")


@setup_logging.connect
def config_loggers(*args, **kwargs):
from logging.config import dictConfig

from django.conf import settings

dictConfig(settings.LOGGING)


# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@
CELERY_WORKER_SEND_TASK_EVENTS = True
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
CELERY_TASK_SEND_SENT_EVENT = True
# https://cheat.readthedocs.io/en/latest/django/celery.html
CELERYD_HIJACK_ROOT_LOGGER = False

{%- endif %}
# django-allauth
Expand Down
38 changes: 38 additions & 0 deletions {{cookiecutter.project_slug}}/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export COMPOSE_FILE := "docker-compose.local.yml"

## Just does not yet manage signals for subprocesses reliably, which can lead to unexpected behavior.
## Exercise caution before expanding its usage in production environments.
## For more information, see https://github.com/casey/just/issues/2473 .


# Default command to list all available commands.
default:
@just --list

# build: Build python image.
build:
@echo "Building python image..."
@docker compose build

# up: Start up containers.
up:
@echo "Starting up containers..."
@docker compose up -d --remove-orphans

# down: Stop containers.
down:
@echo "Stopping containers..."
@docker compose down

# prune: Remove containers and their volumes.
prune *args:
@echo "Killing containers and removing volumes..."
@docker compose down -v {{ "{{args}}" }}
# logs: View container logs
logs *args:
@docker compose logs -f {{ "{{args}}" }}

# manage: Executes `manage.py` command.
manage +args:
@docker compose run --rm django python ./manage.py {{ "{{args}}" }}
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
python-slugify==8.0.4 # https://github.com/un33k/python-slugify
Pillow==11.0.0 # https://github.com/python-pillow/Pillow
Pillow==11.1.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
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 @@ -28,7 +28,7 @@ sphinx-autobuild==2024.10.3 # https://github.com/GaretJax/sphinx-autobuild

# Code quality
# ------------------------------------------------------------------------------
ruff==0.8.4 # https://github.com/astral-sh/ruff
ruff==0.8.6 # https://github.com/astral-sh/ruff
coverage==7.6.10 # https://github.com/nedbat/coveragepy
djlint==1.36.4 # https://github.com/Riverside-Healthcare/djLint
pre-commit==4.0.1 # https://github.com/pre-commit/pre-commit
Expand Down

0 comments on commit 1e9bed3

Please sign in to comment.