deploy django app to python

How to deploy Django apps to Python Anywhere through GitHub?

Let’s look at what is GitHub?

GitHub is a web-based interface that uses Git, the open source version control software that lets multiple people make separate changes to web pages at the same time. As Carpenter notes, because it allows for real-time collaboration, GitHub encourages teams to work together to build and edit their site content. In this blog we will know how can we deploy Django apps to python.


Why use GitHub?

There are a number of reasons.. The first is that it enables slick and easycollaboration and version control. This allows you to work on code with anyone from anywhere. Additionally, many employers use GitHub. So, if you plan on getting a job, you’ll look really good if you already know your way around GitHub. And don’t forget about the connections, learning, and portfolio aspects. GitHub is a robust learning and collaboration platform. Take time to explore it and see just how much it can expand your programming knowledge.

Common terms for GitHub

  • Repository (repo) — a folder in which all files and their version histories are stored.
  • Branch — a workspace in which you can make changes that won’t affect the live site.
  • Markdown (.md) — a way to write in Github that converts plain text to GitHub code.
    Sites such as Atom and Sublime Text are examples of free resources for developers
    using Markdown.
  • Commit Changes — a saved record of a change made to a file within the repo.
  • Pull Request (PR) — the way to ask for changes made to a branch to be merged into
    another branch that also allows for multiple users to see, discuss and review work
    being done.
  • Merge — after a pull request is approved, the commit will be pulled in (or merged) from one branch to another and then, deployed on the live site
  • Issues — how work is tracked when using git. Issues allow users to report new tasks and content fixes, as well as allows users to track progress on a project board from beginning to end of a specific project.
  • Federalist — a platform that securely deploys a website from a GitHub repository in minutes and lets users preview proposed and published changes.

How do I Use a GitHub?

1. Sign up for GitHub
2. Install Git
3. Create a Repository
4. Create a Branch
5. Create and Commit Changes to a Branch
6. Open a Pull Request
7. Merge Your Pull Request

So, I thought it would be amazing if we can just push code onto GitHub and GitHub automatically updates the code on PythonAnywhere and not to mention the default features that are provided by GitHub like Pull Requests, Issues, Actions(haven’t used them till now still a feature) and everything else that GitHub offers.


We will be using something known as Deploy Keys and Webhooks provided by GitHub to
tell our Django Web-App tha it has been updated so it pulls the latest code.
Step 1: Install the Python package named GitPython by using the following command:

Step 2: Write the view function that will receive the update and update the code on the server.
Go to your and add the following code:

You can also send response codes with them by passing the parameter “status” within the
“HttpResponse” that will be returned.

Step 3: Set the URL where the Payload from GitHub will be sent.

To add the payload URL add the following lines into file of your Django Project: