Skip to content

TheRealVizard/django-project-template

Repository files navigation

Django Project Template

Code style: black Django

This is a Django 3.2+/4.0+ project template with my preferred setup.

Installation

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

Features

  • 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.
  1. django-filter for the useful filtering features that provides.
  2. 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",
     },
  3. python-dotenv to set and access environment variables in your settings file.
  4. python-dateutil to handle date and time manipulations.
  5. django-version-checks to ensure you and your team are using the correct Python and DB version.
  6. django-extensions collection of custom extensions for the Django Framework.
  7. django-debug-toolbar is a configurable set of panels that display various debug information about the current request/response.
  8. django-linear-migrations so you and your team keep the migration history clean.
  9. factory-boy super useful to handle Models instance creation for test mostly but also to have a dummy data for demos.
  10. 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)

Deployment

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.

License

Copyright © Eduardo Leyva. Licensed under the BSD 3-Clause License.

About

The Django project template I use.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published