cookiecutter-django icon indicating copy to clipboard operation
cookiecutter-django copied to clipboard

Django server doesn't reload after changes in app

Open BenjaminArmijo3 opened this issue 2 years ago • 11 comments

What happened?

Hi i have used a previous version of cookiecutter-django but the last one doest reload the developent server when the files change

  • Host system configuration:
    • OS name and version: Mac M1

BenjaminArmijo3 avatar Jul 06 '22 18:07 BenjaminArmijo3

Did you use it before on the Mac M1? Did you find some clues on the web about M1 + Django + reloading? Do you use docker?

foarsitter avatar Jul 06 '22 20:07 foarsitter

Did you use it before on the Mac M1? Did you find some clues on the web about M1 + Django + reloading? Do you use docker?

Yes i have an older version running in the same mac that reloads the server and in both i use docker

BenjaminArmijo3 avatar Jul 06 '22 20:07 BenjaminArmijo3

If you have an working version then you are in the position of creating a diff between the projects. My hunche is that it is related to docker, so can you post a diff of local.yml?

foarsitter avatar Jul 06 '22 20:07 foarsitter

the diff is that in the newer version have the line platform, i tried to run with the line commented but the bug persist django: &django platform: linux/x86_64

i think that it could be wathdog but i cant find where it is configured

BenjaminArmijo3 avatar Jul 06 '22 21:07 BenjaminArmijo3

Watchdog is configured through werkzeug in requirements/local.txt. Is your previous project using the stat reloader?

foarsitter avatar Jul 07 '22 07:07 foarsitter

the diff are the versions.

New: Werkzeug[watchdog]==2.0.3 # https://github.com/pallets/werkzeug watchgod==0.8.2 # https://github.com/samuelcolvin/watchgod

Old: Werkzeug==1.0.1 # https://github.com/pallets/werkzeug watchgod==0.6 # https://github.com/samuelcolvin/watchgod

in the Werkzeug the name of watchgod changes to watchdog is it correctly?

BenjaminArmijo3 avatar Jul 07 '22 14:07 BenjaminArmijo3

I change to the older version and it restart with stat.

it seems that the problem is with watchdog

BenjaminArmijo3 avatar Jul 07 '22 14:07 BenjaminArmijo3

See here how werkzeug decides which reloader is uses and here how you can override the setting in runserver_plus.

foarsitter avatar Jul 07 '22 15:07 foarsitter

Hi all, same issue - I just today switched to apple silicon. I had a working project on my intel based mac and then after migrating to the new laptop, I spun up the containers and django was no longer seeing changes.

I think this may be talking about the same problem in this Watchdog issue

camrail avatar Jul 10 '22 12:07 camrail

did you fixed it ?

BenjaminArmijo3 avatar Jul 10 '22 17:07 BenjaminArmijo3

did you fixed it ?

Not a fix but a workaround is to change runserver_plus reloader to stat rather than Watchman given Watchman isn't working. Thanks @foarsitter.

@BenjaminArmijo3 you can add the following line to your local.py settings file. RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'

Unfortunately the reload is takes a bit longer to trigger than you may be used to.

camrail avatar Jul 10 '22 22:07 camrail

For me, switching the dev container to arm64 by removing platform: linux/x86_64 from local.yml did the trick - apparently that's what prevented inotify from working on a mounted volume

Eugeny avatar Oct 20 '22 10:10 Eugeny

switching the dev container to arm64 by removing platform: linux/x86_64 from local.yml did the trick

We just removed that option in #3957. I managed to get my hand on a M1 and test it, can confirm that it was causing the issue. Closing this.

browniebroke avatar Nov 22 '22 22:11 browniebroke