Skip to content

SolanoJason/django-best-practices-template

Repository files navigation

django-best-practices-template

A Django project template that follows best practices. This template is designed to be used with the django-admin startproject command.

Features

Requirements

  • Poetry
  • Django

Usage

  1. 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
  2. Install dependencies using poetry:

    poetry install
  3. Check if everything is working fine:

    python manage.py runserver

How to start an Application inside apps/ directory

  1. Using manage.py:

    cd apps/
    python ../manage.py startapp accounts
  2. Using django-admin:

    mkdir apps/accounts
    django-admin startapp accounts apps/accounts

How to reference Applications

  1. 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'))
  2. For example in INSTALLED_APPS:

    # settings/base.py
    LOCAL_APPS = ['accounts']
  3. For example, to import modules:

    # settings/base.py
    from accounts import models, views, forms

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

Releases

No releases published

Packages

No packages published