How to Deploy Django App Update from Local to Pythonanywhere

Posted: May 23, 2025 | Updated: May 24, 2025

If you want to update your Django app, after you make some changes on your local computer, you have to follow these simple steps.

Step 1: Push your Local app Change to the New GitHub Repository Branch

First, create a new branch for your GitHub repository

git checkout -b new-branch-name

make changes and stage them

git add .

Commit the Changes

git commit -m "Your descriptive commit message"

Push the branch to GitHub

git push origin new-branch-name

Step 2: Pull the New Repository with Code to Pythonanywhere Webapp

On your PythonAnywhere account, go to Web Menu.

Open your Web menu.

Under Virtualenv: section, choose "Start a console in this virtualenv" option. 

On the console, fetch and switch to the branch you want 

git fetch origin
git checkout new-branch-name

Pull the latest changes

git pull origin new-branch-name

Step 3: Download the PostgreSQL backup file from pgAdmin

Open pgAdmin app. Select the database you want to backup.

Right click the database and choose "Backup"

pgAdmin backup PostgreSQL database

Now add a backup name with .sql file extension. Choose a format as "Plain".

backup pgsql db from pgadmin

The backup file will be stored in the Documents folder.

Step 4: Update the LocalPostgreSQL Database Changes to the online One

Upload the PostgreSQL database to the webapp folder.

In Terminal, use the following command to upload the folder to the current Django App PythonAnywhere PostgreSQL database.

psql -h <hostname> -p <port-no> -U <username> -d <database_name> -f <backup_file.sql>

Enter the user password, when it asked. This will overwrite existing data in tables if table names match.

© 2024 Webapptiv. All rights reserved.