Forums

How do you reflect changes to updated code on your local server to the Web App you have running?

Hey Guys,

I ran through the tutorial on Django Girls and succesfully set up a web app for my site: http://tutorial.djangogirls.org/en/deploy/ . I was able to deploy the app from my GitHub account and cloned the repo and set up a virtual environment. I also successfully set up the WSGI.py file.


My question is how do you update your web app after you have made changes locally to your code and pushed the changes (through git) to GitHub? Is there a way to upload your new code from GitHub (maybe git pull -u origin master) through bash and then reload your web app? Right now I see the only way I can update my code is by completely removing my file directory and starting a new web app by performing a git clone on the newly updated repo. This seems like a lot of unnecessary effort. Is there a more efficient way to update your code and reload your web app to reflect changes?

Thank you for your time and help! Please let me know if you have any questions.

You can use the Git push deployment method described at https://blog.pythonanywhere.com/87/ so that when you push an updated copy over it is automatically deployed. How you get it pushed over though is up to you.

If you would like it to be fully automated you can use a continuous integration solution (such as http://www.wercker.com/ for free). It can trigger based off of your commits to Github, run any tests you may have (tests are good!), and then push it over to PythonAnywhere where it is instantly deployed.

You can also push the changes yourself to PythonAnywhere from your local system and use the same deploy method, but that's not automatic.

@jcolp good suggestions!

@cochewen -- if you're talking about a bash console on PythonAnywhere, then all you need to do to update your website with code that you've pushed from your local machine to GitHub is run git pull inside the checkout directory. That is, for the Django Girls tutorial site, start a new bash console, then

cd my-first-blog
git pull

That will pull all of your code changes into PythonAnywhere. Then you need to reload the site, which you can either do by clicking the button on the the "Web" tab, or from Bash by running a command like this:

touch /var/www/cochewen_pythonanywhere_com_wsgi.py

...where the filename is the hostname for your site, with dots replaced by underscores and _wsgi.py added to the end.

thank you!

thanks a lot

Thanks, it helped me

Thank You

Hey, I'm new to PythonAnywhere also and cant figure out how to get updated code in my deployed app. I have tried running git pull and I can see the new files being added in and then, after clicking the reload button, the changes are not present in my deployed app.

Any help would be greatly appreciated :)

Make sure that the code that you have pulled is actually the code that is being run by your web app. Start at the WSGI file (there's a link on your web app configuration page) and follow it back from there.

Hello, I've done the git pull command in my directory but I got an error "error: Your local changes to the following files would be overwritten by merge:" with a list of files, and ask me for 'Please, commit your changes or stash them before you can merge.".

Another error say "error: The following untracked working tree files would be overwritten by merge:" with another list of files, and ask me for "Please move or remove them before you can merge.".

This is probably because I've made (voluntarily) a major change in the structure of my directories. So I would like to overwrite the current working tree files to pull my changes, but I'm not sure how. Should I remove manually all the files listed in order to succeed the github pull?

Thank you in advance for your help.

If the current state is what you want, you should add those and commit them. Look for add, commit and merge in the git docs.

I did some modification in a file in git, then I tried to update this change in pythonanywhere, with git pull command, but I had the same error: " error: Your local changes to the following files would be overwritten by merge: romanianmovies/settings.py Please commit your changes or stash them before you merge. Aborting " What should I do to resolve this ?

git status and git diff should show you the local changes. You can decide if you want to drop them or commit them.