{% comment %}
This is a template for a Django 2.x project.
The project has a layout so that it can be build as a wheel, one type of Python packages.
setup()
is configured using a setup.cfg
file.{{ project_name }}.__version__
.src
directory to prevent side effects.{{ project_name }}.apps
namespace.{{ project_name }}.conf
namespace.{{ project_name }}.conf.settings
uses pathlib
instead of os
and os.path
.Use the following startproject command to create a new project using this template:
python3 -m django startproject --extension=cfg,gitignore,gitkeep,in,md,sublime-project \
--template=https://github.com/keimlink/django-project-package-template/archive/master.zip \
name [directory]
Tip: If you want to create the project in your current working directory use .
as directory argument.
A testbed to quickly test the project template can be found in the separate django-project-package-template-testbed repository.
Distributed under the MIT License.
Copyright 2018-2019 Markus Zapke-Gründemann
All text below the horizontal line is the template for the new project's README.
{% endcomment %}# {{ project_name|title }}
Describe your project in one sentence.
Install the project and the development dependencies into a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install --editable ".[dev]"
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver
First create a new directory in the apps
directory:
mkdir src/{{ project_name }}/apps/name
Then pass the path to the new directory to the [startapp](https://docs.djangoproject.com/en/{{ docs_version }}/ref/django-admin/#django-admin-startapp) command:
./manage.py startapp name src/{{ project_name }}/apps/name
The following list describes only the absolute necessary steps to outline a deployment for a Django project wheel. For example a component to serve static files is missing - you could use WhiteNoise to do this.
Also see [How to use Django with Gunicorn](https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/gunicorn/) and [Deployment Checklist](https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/checklist/) for more information.
install_requires
in setup.cfg
.check-manifest
./setup.py bdist_wheel
dist
directory to the server to be deployed.export DJANGO_SETTINGS_MODULE={{ project_name }}.conf.settings
export DJANGO_ALLOWED_HOSTS=www.example.com
export DJANGO_DEBUG=False
python3 -m pip install --find-links=/path/to/wheel_dir {{ project_name }}
django-project collectstatic --no-input
gunicorn {{ project_name }}.wsgi