0

I'm new to django and have been going through tutorials on udemy and on the django website. I'm using a virtual environment and Bash on Ubuntu Windows.

My issue is that when I update code in any views.py / urls.py files for my project it doesn't "compile" in the .pyc files. So say I add a home page to my urls list I get an error that the page was not found. Once I go back and delete the .pyc files though I can access a home page (or what ever page) I've added. My work around at the moment is that I wrote a python script to delete the .pyc files.

EDIT: I've noticed that this issue occurs when I have two django projects in the same root folder. I made a another user account in the terminal and tried to have two django files in the same root folder and this issue occurred. Is this improper directory set up for django projects?

|-- home
`-- hlat
    |-- djangoproject1
    |-- djangoproject2
hlatimer
  • 73
  • 1
  • 9
  • 1
    how do you run your site? If you run Django with `python manage.py runserver`, you should see that the server restarted after you change the files. – fodma1 Nov 30 '17 at 18:48
  • @fodma1 I run it using python manage.py runserver . when I edit the files I don't see the server restart. – hlatimer Nov 30 '17 at 19:11
  • does it restart after you make changes and save the files? – fodma1 Nov 30 '17 at 19:13
  • @fodma1 I went and added some comments to the views.py file and the urls.py files while running the server and it doesn't restart. – hlatimer Nov 30 '17 at 19:16
  • Make sure none of these cases apply to you https://stackoverflow.com/a/6954870/2419215 – fodma1 Nov 30 '17 at 19:27
  • @fodma1 so If I edit the html on a page and reload the page while running the server I see the changes to my html. Here is what I have in the terminal System check identified no issues (0 silenced). November 30, 2017 - 19:09:15 Django version 1.11.7, using settings 'harrisonblog.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [30/Nov/2017 19:27:18] "GET /home/ HTTP/1.1" 200 344 [30/Nov/2017 19:28:01] "GET /home/ HTTP/1.1" 200 358 – hlatimer Nov 30 '17 at 19:29
  • yes but HTML files are re-read every time you request the page (I think), but python files must be re-loaded. – fodma1 Nov 30 '17 at 19:44
  • @fodma1 I went through the post you suggested and It does not apply to this situation – hlatimer Nov 30 '17 at 19:52
  • @hlatimer can you do an edit on the server and do a `ls -al` where the `.py` and the (unupdated) `.pyc` files are visible? Please paste this into your question (edit) and not into a comment. – hansaplast Dec 20 '17 at 18:56
  • @hansaplast I did as you suggested and it looks like everything is working fine. one thing I did notice is if I leave files I am editing in notepad++ overnight that will not be accessible in bash the next day which results in me having to delete and remake the files. Maybe this was the source of my problem. Still pretty strange – hlatimer Jan 04 '18 at 17:04

0 Answers0