Django React Boilerplate screenshot

Django React Boilerplate

Author Avatar Theme by Labcodes
Updated: 18 Nov 2021
45 Stars

Boilerplate for a Django + React project

Categories

Overview

The django-react-boilerplate is a boilerplate for Django applications with frontend SPAs. It is built by Labcodes and currently uses React and Vite to manage the frontend. The boilerplate is equipped with features such as PWA (Progressive Web Apps) support, HMR (Hot Module Replacement), and code splitting. Although it is still in beta, any bugs that arise can be reported through the issue tracking system.

Features

  • PWA (Progressive Web Apps) support
  • HMR (Hot Module Replacement)
  • Code splitting
  • Easy installation and setup
  • Seamless integration with Django and React
  • Development and testing aids
  • Support for adding new dependencies

Installation

  1. Install the required dependencies:
    • wget
    • make
    • python>=3.6
    • poetry
    • nodejs>=8.10
    • libpq-dev (required for Ubuntu>=18.04)
    • python3-dev (required for Ubuntu>=18.04)
  2. Run the following command to download the boilerplate code, set up nvm (Node Version Manager), and install dependencies:
    wget <boilerplate_url>
    make setup
    
  3. Verify the installation by accessing the server running at localhost:8000 in a browser.

Alternatively, if the setup script doesn’t work or you want to install everything manually:

  1. Download the zip file of the boilerplate from GitHub.
  2. Activate the virtualenv by running poetry shell.
  3. Install all the dependencies by running make install_dependencies.
  4. Copy the env.example file to .env to provide environment variables to the Django app using python-decouple.
  5. Run python manage.py migrate to create a dev database.
  6. Finally, run make run to start both the Vite development server and Django in parallel.

Summary

The django-react-boilerplate is a powerful tool for quickly setting up Django applications with frontend SPAs using React and Vite. It provides features like PWA support, HMR, and code splitting. The installation process is straightforward, and there is also the option to install dependencies manually if needed. The boilerplate offers extensive development and testing support, making it a robust choice for building Django applications with modern frontend technologies.