How To Deploy Django App on Heroku

Hey geeks and really interesting people out there, today we are doing a little resume on how you can deploy django app on heroku.

Yeah, even if you don’t know anything about it, here you can learn how to do it, so keep reading to become a deployer master.

Is kinda obvious, but first, you need to have a Heroku account, is you already have it skip this step, however if you don’t, you can create a Heroku account in like one minute or even less, you can choose the plan that is more suitable for the functionalities you need to have, this platform counts with 4 plans: Free that will cost you $0, and then the ones you need to pay to have, that are hobby, standard, and performance. This time we are working on the free plan.

I need to highlight something really important here, at the moment you create your account,  you choose the “primary development language”, please be sure you select Python. After you finish all the steps you will receive a confirmation email.

Having your account next is installing the CLI for Heroku, this is the main tool you need to interact properly with Heroku, to do this you need first open the console, enter your user-name and password, of the account you already have or just create.

Then start creating a Heroku app, and next you need to connect to PostgreSQL, is kind of easy for those who already have experience on the field.

After you start creating your app, you can start configuring the Django apps for your Heroku system, you can try at first writing a really easy Django application, however, if you are a lot more experienced you can try to do one a little bit more complicated.

You need to have the requirements.txt file, this file contains a list of all you need for app packages, you need to create this file in the root folder. After you have this configured, you need to have the profile, this describes all the commands you will need to execute the app. And last in this step but not least; you need to have the runtime.txt, which is the file that specifies the Python version.

Then we need to separate the Django settings, this is necessary for the app you are creating is this start to grow. After you have it, you need to set up static files. First, you need to modify settings.py ? wsgi.py; that will assure you a correct display of files. After this step, it came the data configuration and the local launch.

If you complete all these steps correctly, you will just need to go and deploy Django to Heroku, run migrations and that’s it! For those who want to take a look at the code here, you have all the information available. It seems really complicated; however, once you achieve it you will feel so satisfied!

Payel Dutta
Payel Dutta
Happy soul, fond of travelling and loves to read tech columns.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Read More

Suggested Post