django-systemd
This is a django admin command that allows you to generate systemd unit files from templates using the django-render-static machinery. It also provides a thin layer on top of systemctl that allows discovery and basic management of the unit files associated with the installed django site environment.
This package makes it easy to do things like, provide a systemd service with your installable Django app or build a full gunicorn service from settings.
django-systemd
django-systemd does two independent things for a Django deployment:
- Generate systemd unit files. Apps bundle unit templates in a
systemd/directory. Render them at package time with known settings and commit the result, or render them at deploy time from live production settings. - Manage the project’s units.
django-admin systemdcan list, install, update, restart and reload every unit the project defines, without you naming them. Units are managed in the system scope by default; privileges come from root, an explicit escalation prefix, or polkit with the link install method. The user scope, with nothing running as root, is still available.
django-admin systemd list
django-admin systemd render ./units --context venv=/srv/app/.venv # in CI
django-admin systemd install --enable # on the host
django-admin systemd reload # on the host
See the documentation for the how-to and settings.
Contributing
Contributions are encouraged! Please use the issue page to submit feature requests or bug reports. Issues with attached PRs will be given priority and have a much higher likelihood of acceptance. Please also open an issue and associate it with any submitted PRs. Before PRs can be merged all added code test coverage must be 100%.
We are actively seeking additional maintainers. If you’re interested, please open an issue or contact me.
Installation
Install Just
We provide a platform independent justfile with recipes for all the development tasks. You should install just if it is not on your system already.
django-systemd uses uv for environment, package, and dependency management. just setup will install the necessary build tooling if you do not already have it:
just setup <python version>
This will also install prek If you wish to submit code that does not pass pre-commit checks you can disable prek by running:
just run prek uninstall
Install the Dev environment
To install all development dependencies run the install recipe:
just install
Documentation
django-systemd documentation is generated using Sphinx with the furo theme. Any new feature PRs must provide updated documentation for the features added. To build the docs run doc8 to check for formatting issues then run Sphinx:
just docs # builds docs
just check-docs # lint the docs
just check-docs-links # check for broken links in the docs
Run the docs with auto rebuild using:
just docs-live
Static Analysis
django-systemd uses ruff for python linting, header import standardization and code formatting. mypy and pyright are used for static type checking. The number of lints or type errors should not increase.
To fix formatting and linting problems that are fixable run:
just fix
To run all static analysis without automated fixing you can run:
just check
Running Tests
django-systemd is set up to use pytest to run unit tests. All the tests are housed in tests/. Before a PR is accepted, all tests must be passing and the coverage must be at 100%. A small number of exempted error handling branches are acceptable.
To run the full suite:
just test
To run the full suite in an isolated environment against a specific Django version (as CI does):
just test-all --group dj52
To run a single test, or group of tests in a class:
just test <path_to_tests_file>::ClassName::FunctionName
Debugging tests
To debug a test use the debug-test recipe:
just debug-test <path_to_tests_file>::ClassName::FunctionName
This will set a breakpoint at the start of the test.
Versioning
django-systemd strictly adheres to semantic versioning.
Issuing Releases
The release workflow is triggered by tag creation. You must have git tag signing enabled. Our justfile has a release shortcut:
just release x.x.x
Just Recipes
bandit # run bandit static security analysis
build # build docs and package
build-docs # build the docs
build-docs-html # build html documentation
check # run all static checks
check-all # run all checks including documentation link checking (slow)
check-docs # lint the documentation
check-docs-links # check documentation links for broken links
check-format # check if the code needs formatting
check-lint # lint the code
check-package # run package checks
check-readme # check that the readme renders
check-types # run all static type checking
check-types-isolated # run all static type checking in an isolated environment
check-types-mypy # run static type checking with mypy
check-types-pyright # run static type checking with pyright
clean # remove all non-repository artifacts
clean-docs # remove doc build artifacts
clean-env # remove the virtual environment
clean-git-ignored # remove all git ignored files
coverage # generate the test coverage report
coverage-erase # erase any coverage data
debug-test # debug a test
docs # build and open the documentation
docs-live # serve the documentation with auto-reload
fetch-refs # fetch intersphinx references for the given package
fix # fix formatting, linting issues and import sorting
format # format the code and sort imports
format-workflows # format the github workflow files
install # update and install development dependencies
install-prek # install git pre-commit hooks
install-uv # install the uv package manager
lint # sort imports and fix linting issues
manage # run the django admin
open-docs # open the html documentation
prek # run the pre-commit checks
release # issue a release for the given semver string (e.g. 1.0.0)
run # run the command in the virtual environment
setup # setup the venv and pre-commit hooks
sort-imports # sort the python imports
test # run specific tests (project venv)
test-all # run all tests (pass --group flags for django version, e.g. --group dj52)
validate_version # validate the given version string against the lib version
zizmor # run zizmor security analysis of CI
Django Commons Code of Conduct
Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
Our Standards
Examples of behavior that contributes to a positive environment for our community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others’ private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at django-commons-coc@googlegroups.com. All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
1. Warning
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
2. Temporary Ban
Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
3. Permanent Ban
Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the community.
Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder.
For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
Security Policy
Supported Versions
Only the latest version is supported.
Reporting a Vulnerability
If you think you have found a vulnerability, and even if you are not sure, please report it to us in private. We will review it and get back to you. Please refrain from public discussions of the issue.
MIT License
Copyright (c) 2026 Brian Kohan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
