DEV Community

Cover image for Automatically deploying Django app to PythonAnywhere through GitHub.

Automatically deploying Django app to PythonAnywhere through GitHub.

Soumya Ranjan Naik on April 03, 2020

This post will explain how to setup automatic deployments to a Django Web-App hosted on PythonAnywhere. What people normally do: 1. Everyone does ...
Collapse
 
gpjt profile image
Giles Thomas

PythonAnywhere dev here -- thanks for the great how-to! Just a quick note, you should add an "import git" to the top of that views.py.

Collapse
 
soumyaranjannaik profile image
Soumya Ranjan Naik • Edited

Thanks for pointing it out. Corrected it.
By the way as far as I know you work pythonanywhere right ? (I have seen your name on forums)

Collapse
 
gpjt profile image
Giles Thomas

Yes, that's me :-) And thanks for adding the correction!

Collapse
 
friedmanyariv profile image
Yariv Friedman

Thanks for the sharing. I followed the path until stumble across: git remote set-url origin git@github.com:USERNAME/REPOSITORY.git then I recieved constantly "
fatal: Not a git repository (or any parent up to mount point /home/donbonbon)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). I actually wasn't sure if I need to use my git repo or pythonanywhere, I ended up testing all.. Noting worked... can you kindly advise. PS - I also tried it on an empty project with the script your recommended... it gave a warning to work only with python 2.7. Any input would be highly appreciated.

Collapse
 
akshayg profile image
Akshay-G-Dev

I know its too late but adding it here for future readers
for some reason git@github.com:USERNAME/REPOSITORY.git doesn't work so instead do this

git remote set-url origin https://{token}@github.com/{username}/{project}.git

and here is steps to create access token for above url, as password access is not supported now

Collapse
 
oaltun profile image
oaltun

Hi there, thanks for the tutorial.

Question: does one still have to push the "Reload ..." button in the web tab in pythonanywhere manually after doing this? Or is this only for getting the code to pythonanywhere?

If it also solves the problem of manual reloading in the web tab, I will give it a go :).

Collapse
 
soumyaranjannaik profile image
Soumya Ranjan Naik

Yeah, you have to. You can also use pythonanywhere API to do it.

Collapse
 
tanuja01 profile image
Tanuja01

Hi,

I'm receiving this error:
cmdline: git pull -v origin
stderr: 'fatal: Could not read from remote repository.
NO MATCH
Please make sure you have the correct access rights
and the repository exists

Please guide me

Collapse
 
tahseen09 profile image
Tahseen Rahman

Awesome!
It's so much fun to learn something new.

Collapse
 
iamgaddiel profile image
Gaddiel Ighota • Edited

Hi everyone,
I know this post has been made since, but I'm having same issues @tanuja01 raised and I can't seem to find anything that address this issue. Due to this the webhook setup on GitHub does not check as okay.
I really need help with this ASAP because my current project I'm working on depends on it.

Collapse
 
asher_not_found profile image
asher

To auto-reload the web app:
pythonanywhere.com/forums/topic/27...

Collapse
 
maneprajakta profile image
Prajakta Mane

Can a private GitHub repo be connected to pythonanywhere.

Collapse
 
soumyaranjannaik profile image
Soumya Ranjan Naik

Yes you can

Collapse
 
maneprajakta profile image
Prajakta Mane

Thank you !

Collapse
 
smyja profile image
Smyja

Spent the whole day setting it up. Thanks, I learnt new things while doing it.