Django Boilerplate

screenshot of Django Boilerplate

Django Boilerplate including PostgreSQL as database, custom user model that uses email as username and dockerized. Based on Python, Django, PostgresSQL, Docker.

Overview

Django Boilerplate is a starting point for Python-Django websites and APIs. It provides a set of pre-configured features and functionalities that can be used as a foundation for developing Django projects.

Features

  • Custom User Model: Includes a custom user model with email and password. The email is used as the username field.
  • PostgreSQL for Database: Configures PostgreSQL as the database backend and provides custom commands for Postgres.
  • Docker Support: Includes support for running the project with Docker. Dockerfile and docker-compose.yml files are provided for easy setup and deployment.

Using Docker

  1. Open a command line window and navigate to the project's directory.
  2. Create a .env file and add the necessary environment variables.
  3. Build the Docker container by running the following command:
    docker build . && docker-compose build
    
  4. Run the project using Docker by executing the following command:
    docker-compose up
    

Without Docker

  1. Ensure that PostgreSQL is installed on your system.
  2. Clone the repository and navigate to the project's directory.
  3. Install the project dependencies by running the command:
    pip install -r requirements.txt
    
  4. Run the database migrations by executing the command:
    python manage.py wait_for_db && python manage.py migrate
    
  5. Finally, start the project by running the following command:
    python manage.py runserver
    

Helpful Commands

  • Make Migrations: To create new database migrations, run the following command:
    docker-compose run --rm app sh -c "python manage.py makemigrations"
    
  • Create Superuser: To create a superuser account, use the following command:
    docker-compose run --rm app sh -c "python manage.py createsuperuser"
    
  • Run Tests: To run the project's tests, use the command:
    docker-compose run --rm app sh -c "python manage.py test"
    

Note: If the application is not an API, remove "djangorestframework" from the requirements.txt file.

Summary

Django Boilerplate provides a solid starting point for Python-Django projects by offering a custom user model, PostgreSQL configuration, and Docker support. It offers easy installation instructions for both Docker-based and non-Docker setups, along with helpful commands for managing the project.