Forums

Cannot update a change to Python Anywhere

Hi,

I am following a tutorial and could deploy my blog to Python Anywhere. However when updating the template (post_list.html), the change is not reflected to the web site. I could see the change in my local computer so post_list.html should be fine.

I could see the change in my Github repository and no error when running git pull on Python Anywhere. I even could see the change in post_list.html from Files tab in Python Anywhere. So it looks like the change was transferred to Python Anywhere.

I clicked "Reload" button but update is not reflected. I tried to log out and log in but this wasn't help

Any help is appreciated.

I could nail down this problem a little more. My header can reflect the change but the problem is the blog post in the database. My post_list.html is updated as in the tutorial at Python Anywhere site but this does not reflect to the live site. I clicked reload button but no update. So looks like blog posts in a database is not updated even it looks fine locally.

Any thought?

Hi again, I figured it out. I learned that I cannot have database both locally and PythonAnywhere. So no issue here now.

Glad you figured it out!

If you need to, you can extract data from your local database and load it into your pythonanywhere database. In django, the commands are manage.py dumpdata app-name and manage.py loaddata, but it's probably simplest to just think of the two databases as totally separate...

Hi! I have the same problem with all updated files at PythonAnywhere but no effect on live site after pushing reload button. Many thanks for any help.

To handle with this problem I had to reload all project from the very beginning.

That doesn't sound right, you shouldn't need to do anything like that. Are you sure you were updating the right copy of the files?

Hi! I have the same problem... I add some buttons on the blog. It works on the local version. I deploy with github, but it still does not work. Do you have a clue ? I am totally new to Pythonanywhere, I followed a Django girls tutorial.

Thanks !

So you added some buttons that exist on local but not on pythonanywhere? did you git pull on pythonanywhere and reload your webapp afterwards?

Yes, I git pull on pythonanywhere, github is up to date and I clicked on the reload button a lot of times without seeing any changes, I checked the orthography, that I was in the right app...

Ok, so finally this problem is solved, I had to re-clone the repo. Thanks a lot!

That's quite weird. Do you mean that your git pulls were not actually working and thus did not update your code, but re-cloning the repo got you the latest version?

Yes... I don't know why, but it works...

Hi same for me I had a problem git pull .. and my git account had the changes reflected as required with git push . I have been looking for the answer everywhere I had to use re cloning and it migrated all of the files as needed. $ git clone https://github.com/myusername/myproject.git

Was git reporting any problems or errors when you did the "git pull"?

Here is the error I was getting 02:41 ~/my-first-blog (master)$ git pull Updating b59313c..c2ee2d9 error: Your local changes to the following files would be overwritten by merge: PythonAnywhere/pycache/urls.cpython-35.pyc app/pycache/models.cpython-35.pyc app/pycache/views.cpython-35.pyc db.sqlite3 Please, commit your changes or stash them before you can merge. Aborting

How do I go about resolving this ?

actually, it still does not work . What it did, it puled another instance of the files into my /my-first-blog and duplicated in the location /my-first-blog/my-first-blog ... So pulling did not actually work. just created a duplicate , Any help is much appreciated on using the pull command . My code is updated on GitHub and I can not figure out why I get the Error for the pull . Thank you in advance.

You're getting errors because you have changes in your local copy that would be overwritten by the pull (see the error message). The __pycache__ directory is a cache for Python bytecode that is regenerated when you run your code. It's a really bad idea to include it in your repo. Remove it from the repo and add it to gitignore to avoid committing to it in future, then try pulling again.

Sorry, this was a double post, and I'm not quite sure how to delete a comment.

I'm having a similar error. I'm getting the following error in the Bash console on PythonAnywhere.com:

"(myvenv) 09:48 ~/my-first-blog (master)$ git pull
error: Your local changes to the following files would be overwritten by merge:
    mysite/wsgi.py
Please, commit your changes or stash them before you can merge.
Aborting"

I've reached the last section of the HTML part of this tutorial https://tutorial.djangogirls.org/en/html/, the "One more thing: deploy!" section.

I've set up my GitHub account and PythonAnywhere according to the "Deploy!" part of the tutorial https://tutorial.djangogirls.org/en/deploy/. I successfully was able to get the website to pull successfully once. The tutorial had me edit the mysite/wsgi.py file on the PythonAnywhere website, and I suspect this is what is causing the issue. I've updated the site on my local files and have pushed to GitHub, but I am not able to pull it to the PythonAnywhere site.

*I fiddle around with things, and got the site to work, by using the "$ git commit -m "your mother"" command. I then tried to pull, and the Bash console state that the site was already updated. I'm not sure what I did, to be honest.

I think the problem was that you edited the wrong WSGI file -- the tutorial tells you to change the one in /var/www/<your-PythonAnywhere-username>_pythonanywhere_com_wsgi.py (there's a link to it on the "Web" tab), not the one in mysite/wsgi.py.

Anyway, it sounds like you worked out a solution...?

I have also had this problem. I think is related to those pycache files. But I dont know how to handle them properly. One wokaround I found was reseting the git log on pythonanywhere a couple of commits back. like this: git resret HEAD~2 and making a new git pull. Then the new pull worked as it should, displaying the most recent changes.

But this has happened before and I remember I found in some forum a console comand in order to "flush" the pythonanywhere chache after a pull, however I am not able to find it again. If someone knows about this command I am talking about please tell us.

I don't know what you mean by flushing the cache (what cache?). Do you mean reloading the web app. From a a command line, you can do that by touching the wsgi file for the web app.

error: Your local changes to the following files would be overwritten by merge: mysite/settings.py Please, commit your changes or stash them before you can merge.

i have this error please give me the solution at the time of pull request

It sounds like you've made a change to that file on PythonAnywhere. So git is telling you that if you do a git pull, it will pull down a new version of the file, which will overwrite your changes. What you need to do depends on whether or not you want to keep the changes you've made on PythonAnywhere, or replace them with the ones you made locally and pushed to GitHub, or whether you want a combination of the changes on both sides.

I faced the same issue. Using git reset --hard before git pull solves the problem.

That's not a general solution. git reset --hard discards any local changes. It may allow you to pull after you've done it, but it may also destroy data that you wanted to keep. If you get the message that there are local changes, you need to actually look at those changes to see whether they are changes you want to keep.

This do the trick.

"I faced the same issue. Using git reset --hard before git pull solves the problem."

Hello,

I'm facing the same issue.

I've also reached the last section of the HTML part of this tutorial https://tutorial.djangogirls.org/en/html/, the "One more thing: deploy!" section.

I've set up my GitHub account and PythonAnywhere according to the "Deploy!" part of the tutorial https://tutorial.djangogirls.org/en/deploy/. The "Django: the install work!" home page appeared succesfully. I didn't edit the mysite/wsgi.py file on the PythonAnywhere website (didn't find that part in the tutorial).

I've updated some code on my local files and have pushed to GitHub, and I have pulled the latest commit. It says that it's "Already up-to-date.", and I'm able to see my newest files on Files in PythonAnywhere. However, when I reload my Web app, I don't see my changes and the home screen. I'm still seeing the "Django: the install work!" page.

I've tried:

  • $ git commit -m "asdf"" command, and after: $ git pull

  • $ git reset --hard, and after: $ git pull

But they don't seem to work... any advice?

Did you reload your web app using the reload button on the web app configuration page?

yes, I've reload the web app using the green reload button, but I'm still seeing the "Django: the install work!" page.

I had to reconfigure my WSGI file (because it was pointing to the wrong code), and it worked!

thank you so much for your help!

Great. Glad you could solve it.

Hello! I have a problem with updating my code from GitHub to Python Anywhere. I am following Django Girls Tutorial. I've updated some code on my local files and have pushed to GitHub with new commit. I could see the change in my Github repository. Then I tried 'git pull' at Python Anywhere and I saw this message:

Updating ebefb9b..75b3566 error: Your local changes to the following files would be overwritten by merge: blog/templates/blog/base.html blog/templates/blog/post_detail.html blog/views.py mysite/settings.py mysite/urls.py Please, commit your changes or stash them before you can merge. error: The following untracked working tree files would be overwritten by merge: blog/templates/registration/login.html Please move or remove them before you can merge. Aborting

I need some advice, thanks.

so you have made some changes on PythonAnywhere, and then you tried to git pull.

You probably need to git add, git commit and git push before you can git pull.

"You probably need to git add, git commit and git push before you can git pull" - where do I have to do these commands: on my local console or on PythonAnywhere bash console?

if you have made change on PythonAnywhere then you need to do it on PythonAnywhere, or you can discard the changes you made.

Okey. Thanks, I'll try.