Forums

How to redeploy django project from GitHub to pythonanywhere

Dear pythonanywhere support team,

I have successfully deployed my django site on pythonanywhere. However, there is a problem with admin data entry. I needed to fix my codes of the django project on my pc and I have commited it to my GitHub repository, but I don't know how to redeploy it to pythonanywhere. Using bash command of 'git clone url from cloning' is not allowed since there is existing project.

Thank you in advance.

you need to git pull in the directory and then reload your web app.

Thank you for your helpful clue. I followed these steps, and it worked:

-First reset to get all changes from GitHub to pythonanywhere by: —> git reset --hard origin/main —> git pull 
_Then, deal with Error of Disallowed Host

However, the previous problem stills come -- the admin page of my site with format and table problem. The same cause is the confusing version of Pil or Pillow. Probably, I just do the data entry from my mac and commit to GitHub repository and do the above steps all the time.

Make sure that you are serving the static files necessary for the styling of your pages: https://help.pythonanywhere.com/pages/DjangoStaticFiles/

What are you finding confusing about PIL and Pillow?

Like I suspected, now the uploading of image via my site admin page got this:

ImportError at /admin/newsapp/post/add/ cannot import name '_imaging' from 'PIL' (/home/ReksmeyOk/myMainProject/venv_myVirtual/lib/python3.8/site-packages/PIL/init.py)

Could you help me please. Thank you in advance.

From this ticket(comment by nscedetas), it appears that you may have different versions of PIL or Pillow that are causing problems for you. Delete and rebuild your virtualenv, so that you only have one version that was ever installed in the virtualenv.

Yes, it actually is. My intended Python version is 3.8.5, but when I checked it in the pythonanywhere's virual env the version is 2.7.12.

So I deleted and rebuilt the virtaulenv. However, the Python version 3.8.5 doesn't exist, so I typed Python version 3.8 which I know will be conflicting with my project codes.

And after rebuilding virtaulenv and reloading the web, it came out something went wrong on my site. Is there any more fix to this python version rather than rebuilding my project with python version 3.8 and commit it to GitHub and rehost it to pythonanywhere again?

Thank you in advance

I'm confused, first you say you want to use Python 3.8, then you say that it will conflict with your code. Which is it?

You need to specify the version of Python that you want to use in a virtualenv (3.6, 3.7, 3.8 etc): https://help.pythonanywhere.com/pages/RebuildingVirtualenvs/

Also, it sounds like you're building your virtualenv and then commiting it to git to use on PythonAnywhere. That will not work. Virtualenvs cannot, in general, be copied from machine to machine. Create the virtualenv on PythonAnywhere if you want to use it on PythonAnywhere.

if you use git pull what about your database

What about it?