Skip to main content

Django starter project template. Dockerized Django serving a static React app

Project description

Starter project template: Dockerized hybrid Django React app

Starter project template using docker to build a Django app that serves React apps statically (as JavaScript files)

Stack:

  • Django (with Rest framework, PostgreSQL, SMTP gmail backend, whitenoise, etc.)
  • React (bundled with webpack and transpiled with babel)
  • Docker
  • Deployment to Heroku

First Setup

  1. Make sure poetry is installed pip install poetry
  2. Execute python setup/run.py or py setup\run.py
  3. After the project is setup, start the docker container to start working docker-compose up -d. The "setup" folder will delete itself after setting up the project, as to leave a cleaner project.

Debugging with Docker and VSCode

Support for debugging remotely if you're running with Docker is supported out-of-the-box.

To debug with Docker:

  1. Rebuild and run your Docker containers as usual: docker-compose up --build

  2. Start the debug session from VS Code for the [django:docker] runserver configuration

    1. Select [django:docker] runserver from the dropdown near the Play button in the top left.

    2. Hit the Play button or hit F5 to start debugging

      • Logs will redirect to your integrated terminal as well.
  3. Set some breakpoints in functions or methods executed when needed. Usually it's Model methods or View functions

Adding external libraries

It's better to install external libraries from from Docker directly

  1. Python libraries:
    1. docker-compose exec web poetry add [pip_package] for production libraries
      • Example: docker-compose exec web poetry add django-extensions
    2. docker-compose exec web poetry add [pip_package] --dev for development libraries
      • Example: docker-compose exec web poetry add --dev selenium
  2. JavaScript libraries:
    1. docker-compose exec web npm install [npm_package] for production libraries
      • Example: docker-compose exec web npm install lodash
    2. docker-compose exec web npm install -D [npm_package] for development libraries
      • Example: docker-compose exec web npm install -D jest

Deploy to Heroku

First setup

Followed guide of "Django for professionals" book

Consecutive deployments to production

Deploy by pushing to Heroku git repository: git push heroku main

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hybrid-django-react-0.0.7.tar.gz (60.5 kB view details)

Uploaded Source

Built Distribution

hybrid_django_react-0.0.7-py3-none-any.whl (67.3 kB view details)

Uploaded Python 3

File details

Details for the file hybrid-django-react-0.0.7.tar.gz.

File metadata

  • Download URL: hybrid-django-react-0.0.7.tar.gz
  • Upload date:
  • Size: 60.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Windows/10

File hashes

Hashes for hybrid-django-react-0.0.7.tar.gz
Algorithm Hash digest
SHA256 1053c1f94c5b9933b747a468aab17785072926acce7bcecddd3b899750998a8a
MD5 63c23b4b1b997d3b098490d2b2a31873
BLAKE2b-256 30654b1ad5ccb2c26ab98f99615f5850767231d1bfba034edd13e8823c782e9f

See more details on using hashes here.

File details

Details for the file hybrid_django_react-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for hybrid_django_react-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b64cb8657362e7eea28a51ce1c58157169c1baec7c6989573fee6f588d1f3f70
MD5 20a2a36b375a16d955929d31d5075f42
BLAKE2b-256 ef5eeb91f32adbe43f071f719f5cfd7fd9b3e8cb27159cdc04283ba0e444b872

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page