Template for a basic Django 4.0 site, with some helpful base objects, Bootstrap 4.6.0, FontAwesome 5.15.3 Free version, and starter templates.
django3-site-template
to django-bootstrap-template
. This is more in line with what the template actually contains, and no longer ties it to a specific Django version.Full template changelog: https://github.com/GriceTurrble/django-bootstrap-template/compare/v2021-11-01...v2021-12-09
Django 4.0 release notes: https://docs.djangoproject.com/en/4.0/releases/4.0/
Bumped Django dependency to 3.2.9 (Django release notes).
pytz
in favor of zoneinfo
(see Django 4.0 release notes). So, specifying this sub-dependency in the template may lead folks the wrong way moving forward.django-environ
bumped to v0.7.0.Dependencies have been updated to use compatible release format, setting the minimum versions for packages and allowing later patch versions to be installed more easily.
Have also changed the psycopg2
dependency (for those who might use it) to psycopg2-binary
. I find the latter easier to work with in most scenarios.
Finally, set the min version for pytz
. Can never be too careful with that one!
The template now starts at Django 3.2, which was released on April 6, 2021.
Details: https://docs.djangoproject.com/en/3.2/releases/3.2/
Notable changes to this template:
primary_key=True
.
DEFAULT_AUTO_FIELD
has been added to settings.py
ProjectBaseModel
renamed to MyBaseModel
.
ProjectBaseQuerySet
and ProjectBaseManager
also renamed to MyBaseQuerySet
and MyBaseManager
, respectively.core
directory (see next change).settings.py
and root urls.py
files, has been renamed to core
.
startproject
command create directories by the same name, such that you'd find settings.py
at my_project/my_project/settings.py
. This can be a stumbling block for some newcomers, and the purpose of this subdirectory named the same as the project is often unclear.core
pattern, helping distinguish the "core" of the project from the other apps contained therein.core/
directory instead of a directory named after your project slug.base_objects
app has been removed. The objects that were defined there now live in the core
directory.
I found no reason to maintain that pseudo-app structure when it only contains abstract models and associated helper classes.
Using the new template, there is no need to list an extra "app" in settings: just import objects from core
like any other Python package. For instance:
from core.models import MyBaseModel
class MyModel(MyBaseModel):
...
.env
file was not being read by django-environs properly due to a missing line in settings.py
. This has been corrected, so new projects should be able to start up smoothly.Increases minimum version for Django to 3.1.1, based on a security release.
Details: https://docs.djangoproject.com/en/3.1/releases/3.1.1/
The project template has been updated with the following helpful features:
django-environ
has been added as a project requirement, in order to easily inject environment variables to the project settings.
<project>/settings.py
now uses env(...)
calls to get settings like DEBUG
and SECRET_KEY
.cookiecutter
.Two new cookiecutter options are available, database_backend
and open_source_license
.
database_backend
, provides a selection between sqlite3
(Django's default, enough for small prototype projects) and postgres
.
postgres
is selected as the backend:
.env
file for POSTGRES_NAME
, POSTGRES_USER
, etc.settings.py
is adjusted to use the postgres backend and the environment variables specified above.requirements.txt
is updated to include psycopg2
, which is needed for Python to interact with a Postgres database.open_source_license
, allows selection of the type of license to use, instead of forcing the MIT license.
pydanny/cookiecutter-django
Not open source
will remove all open-source license files from the project.Added requirements-dev.txt
to template project. This includes pytest
and pytest-django
for testing (with a pytest.ini
file included that should help you get started), and black
for code formatting (recommended, though not required).
pytest-django
.base_objects
app will be added in a future update.README.rst
added to the template project. Partly borrowed from pydanny/cookiecutter-django
, adjusted to point to this site template. :)
A full .gitignore
file is included with the template project, as a copy of this project's .gitignore
. This helps get your new project going while keeping safe from committing the wrong types of content (like the new .env
file with all your secrets!)