This is a Django 3.2+/4.0+ project template with my preferred setup.
Installing the template is easy, just run:
django-admin startproject <project_name> \
--template=https://github.com/TheRealVizard/django-project-template/archive/main.zip \
--extension py,cfg,yml,ini,toml,env,example,prod,conf,json \
--name Dockerfile
- Comes with Django 4.0.6 by default.
- More comfortable project structure.
- Uses Poetry to manage the packages installation.
- Settings divided for develop and production.
- pre-commit configured with many useful hooks.
- Docker file configured for production environment.
- Base custom HTML template with Bootstrap 5, Font Awesome 6, jQuery 3.6 and Select2
- Base TrackedModel class to track model changes.
- Few third party packages really useful for develop and production.
- django-filter for the useful filtering features that provides.
- django-select2 to simplify the selection to the end user interface. For this package I also include a custom CSS and JS to add the look and feel of Bootstrap 5 and the Spanish language to the UI. You can change these in the widget declaration as follows.
widget=ModelSelect2Widget( attrs={ "data-theme": "bootstrap-5", "data-language": "es", "data-width": "style", },
- python-dotenv to set and access environment variables in your settings file.
- python-dateutil to handle date and time manipulations.
- django-version-checks to ensure you and your team are using the correct Python and DB version.
- django-extensions collection of custom extensions for the Django Framework.
- django-debug-toolbar is a configurable set of panels that display various debug information about the current request/response.
- django-linear-migrations so you and your team keep the migration history clean.
- factory-boy super useful to handle Models instance creation for test mostly but also to have a dummy data for demos.
- pytest to write all your test for the project. Comes with several plugins (pytest-cov, pytest-django,pytest-randomly, pytest-restrict, pytest-xdist, pytest-env)
For the deployment it uses Gunicorn, Nginx to handle the server, by default uses PostgreSQL for the database. In the Dockerfile you will se this --with production
in the poetry decencies installation, production is a custom group that you can use to manage the production dependencies. For the production environment the default .env file used is the .env.prod file.
Copyright © Eduardo Leyva. Licensed under the BSD 3-Clause License.