Forums

views.py, urls.py not updating

Hi,

I'm facing difficulty trying to get my Django web app to reload properly upon updating urls.py and views.py. Static files do refresh in my browser but not the .py files, it seems.

Previously I had this problem when trying to create new urls on urls.py, and was facing constant 404s. I've managed to work around this by forcing the .py files to reload by adding a new arbitrary variable in views.py and loading that through a Django template in a page, as suggested at http://stackoverflow.com/questions/18234893/django-urls-inconsistent-and-now-returning-404 where I asked a question.

So that worked then, but now, it seems like that fix is not working anymore and my changes in views.py and urls.py cannot be reflected in my browser.

I'm sorry but I'm unable to make logic out of these symptoms. Any suggestions?

This might be a silly question, but are you hitting the "Reload" button on your web apps page after making the changes?

Like other production-level environments, PythonAnywhere doesn't automatically reload your web app every time you change a file -- it would slow things down too much.

<!-- Oh yeah sorry about missing out the most important points.

Yup I've been mashing it non-stop. In fact, it's been a day or two now since I've edited the files and my {{ random_variable }} still isn't showing up in my template, nor can I get a HttpResponse('random_string') from another URL I had created at the same time. -->

Okay so that was what I wanted to post originally, but just to be sure before I posted, I refreshed the pages (without hitting the reload button), and it seems like everything's working just fine. That is so weird. Anyhow, it's fixed so I'm not complaining! But it would be wise to try to deduce what was the cause of it so as to be able to avoid the same problem the next time round I guess.

It seems like that was a one-off; the views.py file isn't refreshing on me again :/

Looking at it now... which web app is it? Send me a message with the "Send feedback" link at the top if you don't want to post the domain name here.

One possibility -- and again, sorry if I'm telling you something that's already painfully obvious to you ;-) -- is that you're not reloading the right app. There's a separate button for each web app, and you need to select the app to reload from the list on the left to show it. My guess is that you already know this, though, as the buttons do have the name of the domain that's going to be reloaded on them...

But if it's not that then I'm kind of at a loss -- I really can't repro the problem on any Django apps I create myself. Just to make sure I understand exactly what you're seeing, could you confirm (or correct) the steps below:

  • You're making a change to the code for a particular web app, let's call it www.foo.com, adding a new URL to urls.py.
  • You're going to the web apps page and selecting www.foo.com from the list on the left.
  • You're clicking the "Reload www.foo.com" button.
  • Once the "spinner" next to the button has disappeared to let you know that the app has finished reloading, you're visiting www.foo.com and going to a URL that you've added or updated
  • You're not seeing the expected changes.

Is that right?

Giles. You were right. I didn't click the right reload button. I am really, really sorry for all the inconvenience. >.<

No problem at all, glad we worked it out!