A Django project template that follows best practices. This template is designed to be used with the django-admin startproject
command.
- Organized project structure
- Settings module split into base, development, and production settings
- Integration with
django-extensions
,django-debug-toolbar
,flake8
,black
- Includes basic setup for static files and templates
- Poetry
- Django
-
Create a Django project:
django-admin startproject --template=https://github.com/SolanoJason/django-best-practices-template/archive/main.zip --extension=py,toml,env projectname
cd projectname
-
Install dependencies using poetry:
poetry install
-
Check if everything is working fine:
python manage.py runserver
-
Using manage.py:
cd apps/
python ../manage.py startapp accounts
-
Using django-admin:
mkdir apps/accounts
django-admin startapp accounts apps/accounts
-
In order to import applications from the apps/ directory, we must assume the application is in the root directory. This is achieved thanks to the following line of code in settings:
# settings/base.py sys.path.insert(0, str(BASE_DIR / 'apps'))
-
For example in
INSTALLED_APPS
:# settings/base.py LOCAL_APPS = ['accounts']
-
For example, to import modules:
# settings/base.py from accounts import models, views, forms
Contributions are welcome! Please fork the repository and submit a pull request.