- Notifications
You must be signed in to change notification settings - Fork21
From hello world to Heroku deployment, using separated Front and Back Ends
License
ohduran/cookiecutter-react-django
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Powered byCookiecutter, Cookiecutter React Django combines the capabilities of Django as a backend service with the flexibility and ease of use of React into the least opinionated framework possible that allows you to jumpstart a production-ready web application.
Latest versions of Python, Django and React: With the latest security updates and the newest features available.
Docker: Your app becomes a lightweight, standalone, executable package of software.
WhiteNoise: Radically simplify static file serving for your web app.
Heroku ready: Create an app, set up the configuration and deploy.
Let's assume that you want to create a project called "hello_world", one that makes a separation between a React-based front end and a Django-based backend, all set up locally using Docker and production ready in Heroku.
Most tutorials will give you a partial solution, so the only way is painstakingly piecing it together from multiple guides/tutorials that did some aspect of what you want without covering the whole.
Side projects don't exactly require optimal productivity, but, unlike jobs, if they become a pain to work on, it's pretty easy to just quit.
Instead, we can do as follows. First, get Cookiecutter:
$ pip install "cookiecutter>=1.7.0"
Now run it against this repo:
$ cookiecutter https://github.com/ohduran/cookiecutter-react-django
You'll be prompted for some values. Provide them, then the project will be created for you.
Now, on your terminal, simply dodocker-compose up --build, and wait for the containers to build. Eventually, you'll be able to see the index page by going tohttp://127.0.0.1/:
You will be able to see the following:
Write something on that box over there, it will get you the number of characters via your Django API!
To learn more about contributing, please readour contributing docs.
This project is based on a series of tutorials written byCraig Franklin calledCreating an app with Docker Compose, Django, and Create React App.
If you're new to Heroku, theirgetting started guide will walk you through the basics of creating a generic, non-dockerized Python app. If you don’t have it yet, install theHeroku CLI.
We can create a Heroku app by running
heroku createwithin our project. Once you've done it, Heroku will provide you with the following message:Creating app... done, ⬢ one-example-12345https://one-example-12345.herokuapp.com/ | https://git.heroku.com/one-example-12345.gitIn this case,
one-example-12345is the name of the app; yours is likely to be different.Make sure you link the Heroku app with your repository by running
heroku git:remote -a [app name].For environment variables in production, you can set the config variables by running the following command:
heroku config:set PRODUCTION_HOST=[app name].herokuapp.com SECRET_KEY=[your secret key] DJANGO_SETTINGS_MODULE=backend.settings.productionYou can generate a valid Django Secret Key viathis link. REMEMBER to put the key between apostrophes ('), or you will likely get a
-bash: ****: event not foundNow run
heroku stack:set containerto tell our Heroku app to use Docker.At this point, you're ready to deploy: run
git push heroku master.Checkout https://[app name].herokuapp.com. You should be able to see your web app ready!
About
From hello world to Heroku deployment, using separated Front and Back Ends
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.

