What is Django?
Django is a Web development framework written in python which is free and open source. Django framework is based of the Model-View-Template (MVT) and now it has a large community based around the world. Some of the world famous applications like Instagram, YouTube, Spotify and Bitbucket and many other applications are using the Django framework to build their applications.
Now let’s have a look about What is Heroku?
Heroku is a cloud platform which is capable of supporting several popular programming languages such as Python, PHP, Java, Node Js, Scala and many others. The Heroku cloud service platform is based on a managed container (called dynos within the Heroku paradigm) system with integrated data services which allows users to run their website or any modern application. It has a very broad range of dynos and pricing is very reasonable.
Make sure you have installed Git and the Heroku CLI on your machine.
- Git Installation Guide
- Heroku CLI Installation Guide
Please note that the following steps are suitable for the developers who build their application on Windows Operating System and If you are using any other OS, the following steps may be different.
Let’s move forward.
Initialize a local Git repository, commit and push your application code in to it.Move inside your project destination and run following commands.
git initgit add .git commit -m "initial commit"git push origin master
Creating Heroku remote
For a New Heroku App run the following commands.
heroku creategit remote -v - (To check whether you have correctly set the remote)
For an Existing Heroku App
heroku git:remote -a your_heroku_app_name
Create a free account on Heroku. You can create your account from www.heroku.com
Create a new app for your application with the prefix of -app.
If you are not logged into your heroku account, Open the command prompt in windows (CMD) and run the following command.
After you run this command they will ask you to enter any key to login and then you will be redirected the Heroku login screen.Once you clicked the login button you will be automatically logged in and in CMD you can see it with your email as shown in the example below.
Lastly , Deploy your project on Heroku.
git push heroku master
If you have successfully deployed your project, the URL to your website will be shown at the bottom of the page. Copy and paste that URL in the browser to visit your hosted website.
Well-done! You have just deployed your Django project on Heroku.
Thanks for reading and feel free to comment and share it with your friends.