Use this cookiecutter template 🍪 to start every new Python Django project.
- Git
- Python 3.11
- Poetry 1.2.x
- Pre-commit hooks
Create a new Python Django project
cookiecutter gh:papamana/cookiecutter-django
Create a new Python Django Project with Spesific Release version
cookiecutter gh:papamana/cookiecutter-django --checkout <release version>
example:
cookiecutter gh:papamana/cookiecutter-django --checkout v0.1-beta.1
For Windows, you might need to run python -m cookiecutter
as the command might not work even though it's correctly configured on the PATH.
The template covers your back with the following elements:
- README.md with a pre-defined structure.
- CHANGELOG.md file with an initial message.
- Stub project template.
- Test directory with a sample test file.
- GitHub workflow configuration to run pytest automatically.
- Pre-configured mypy, Flake8, isort.
- A set of pre-commit hooks.
- pyproject.toml for Poetry.
Before creating a project:
- Install Poetry.
- Install pre-commit.
- Choose a project name. Likely, in the format
foo-bar
and create a GitHub repository for it. The root package of your project will have a default namefoo_bar
. Make sure that you made the repository private if you plan to create a private (non-open-source) project. - Choose the license. For public projects, use MIT. For private projects, use "Proprietary."
The project generation runs these steps:
- Creates a new project from the template.
- Initializes a GitHub repository.
- Installs pre-commit hooks and updates all hooks to their latest versions.
- Create an initial commit.
After creating a project:
- Initialize the virtual environment and install all dependencies with
poetry install
. - Deploy changes to GitHub.
- For Windows, you might need to change your access token to GitHub. See information here
Other hints:
- Use How to Write Good Documentation to fill in our README with the content.
- Use Keep a Changelog guideline for your changelog entries.
A file .github/workflows/tests.yml
is responsible for running tests on GitHub.
At the moment, VSCode doesn't automatically detect Poetry environments. You can set it
manually, though. For a newly created project, create a .vscode/settings.json
poetry install
mkdir -p .vscode
cat <<EOF > .vscode/settings.json
{
"python.pythonPath": "$(poetry env info -p)/bin/python"
}
EOF
Ref: microsoft/vscode-python#8372
If you use VSCode and the vscode-dotenv
extension, add the following lines to your .vscode/settings.json
file:
"files.associations": {
"env.example": "dotenv",
"env.github-actions": "dotenv"
}
- If you have questions, ideas or suggestions, write them down in an issue.
- If you have a fix or an enhancement, create a pull request.