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
- Make sure poetry is installed
pip install poetry
- Execute
python setup/run.py
orpy setup\run.py
- 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:
-
Rebuild and run your Docker containers as usual:
docker-compose up --build
-
Start the debug session from VS Code for the
[django:docker] runserver
configuration-
Select
[django:docker] runserver
from the dropdown near the Play button in the top left. -
Hit the Play button or hit
F5
to start debugging- Logs will redirect to your integrated terminal as well.
-
-
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
- Python libraries:
docker-compose exec web poetry add [pip_package]
for production libraries- Example:
docker-compose exec web poetry add django-extensions
- Example:
docker-compose exec web poetry add [pip_package] --dev
for development libraries- Example:
docker-compose exec web poetry add --dev selenium
- Example:
- JavaScript libraries:
docker-compose exec web npm install [npm_package]
for production libraries- Example:
docker-compose exec web npm install lodash
- Example:
docker-compose exec web npm install -D [npm_package]
for development libraries- Example:
docker-compose exec web npm install -D jest
- Example:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hybrid-django-react-0.0.2.tar.gz
.
File metadata
- Download URL: hybrid-django-react-0.0.2.tar.gz
- Upload date:
- Size: 60.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc2bd838db9401395128e258dfd0579b71f2cde4513e97bab3deacf47ca8a859 |
|
MD5 | c39c671665417aca6e8361ec87f74126 |
|
BLAKE2b-256 | 2f9081adf9596e23b4e213ddf34aaf4142646040e725a1d7dd6e490d193ac855 |
File details
Details for the file hybrid_django_react-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: hybrid_django_react-0.0.2-py3-none-any.whl
- Upload date:
- Size: 66.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.6 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4edefad6af0e4f913299a9ae0a8039c2db8c4ea4a5c1c393bfcf91da3b501fad |
|
MD5 | dfe353e0e2240c2b261db9eb6d5f0743 |
|
BLAKE2b-256 | 1530aee36560e469bfcb93d1d77d18cb7da091442d2b7a81ccae8289b73a8718 |