#22729 closed Uncategorized (invalid)
Runserver’s autoreload not monitoring views.py & urls.py
Reported by: | Guilhem Saurel | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.7-beta-2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
It seems that a touch on a views.py or an urls.py does not trigger the runserver's autoreload as it does with any other files I tested.
I dig a little to see how this should work, and in utils/autoreload.py there is that function gen_filenames() which looks for sys.modules.values(), so I tried that in a ./manage.py shell:
import sys list(filter(lambda x: 'home' in x, [filename.__file__ for filename in list(sys.modules.values()) if hasattr(filename, '__file__')]))
which should show the monitored files in my project, and it lists settings.py, models.py, init.py and even some other of my scripts, but no views.py or urls.py.
Any clue ?
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
PPS: oh, ugly filter:
[filename.__file__ for filename in list(sys.modules.values()) if hasattr(filename, '__file__') and 'home' in filename.__file__]
comment:3 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The reloading code only monitors imported files (aka sys.modules). When you launch runserver
and no requests have been made, urls.py
might not have been imported yet, so no need to reload the module after any modification. After each request, the list of monitored files is updated, so if you touch urls.py
after a request has been made, you should see the autoreloader in action. I think this is expected behavior.
PS: I tried those «touch» with Python 3.4.1 - Django 1.7.0b4 and Python 2.7.6 - Django 1.6.5, with same negative results