tjwalch/django-livereload-server

Channels compatibility

namedots opened this issue · 13 comments

Should this project work with https://channels.readthedocs.io ?

In my attempts django-livereload-server doesn't inject livereload.js, and when doing so manually the refresh is sent out before ./manage runserver has finished restarting.

No, it doesn't work with channels (yet). Unfortunately channels patches out the runserver command in an incompatible way. Probably not a huge fix if someone has the need and the time to fix it.

HELLO .... to make it work with channels .. do this

in you wsgi.py file :

  • import the variable application from your asgi.py file as asgi_application (you can choose any name)
  • change
    this -> application = get_wsgi_application()
    to -> application = asgi_application

Have you tried it and it works? Because that wasn't the problematic thing, it had to do with runserver command.

@tjwalch for me the runserver command never works ... i always do runserver in a terminal an livereload on another

Yes that's how you need to do it, it is two processes as stated in the instructions. But you need livereload-servers's patched runserver to get livereloads on python file changes. And this wasn't working with channels.

it's working normally ... in fact i stopped doing this hack all together, i just cloned the repo instead of using the pip install method and it's working just fine without any modifications....
it's not the app that's incompatible with channels
most people using channels don't know the proper way to set up a project

proof /
image

If livereload-server was working properly the runserver command would issue a livereload request after start/restart. And it doesn't according to your printout.

@tjwalch

image

it's working without a problem

i tool the picture as soon as i started the server that's why you didn't see it

the issue that needs to be fixed isn't the server not starting issue ... it's working normally and i've been using it, the issue that needs to be fixed is to ignore web socket messages, because every time the server sends a message to the client .. the livereload app is reloading the client

PS:
when i used the pip install method i had to use the workaround mentioned above to get this to work, but when i cloned the repo and added the app manually to the project, it worked normally without having to apply the workaround .... that's why i opened an issue saying that you have to launch a new release

You don't seem to understand how livereload-server is supposed to work and what's not working with channels. The problem isn't livereload command but runserver - but you show me livereload output.

  • I don't see the point in issuing a new release with the same code? You are free to submit a PR if you think you have improvements.

what is wrong with the runserver command ? i mean, everything is working properly for me ... i'm using channels 2

Do you get livereload requests when python files are changed and devserver has restarted? According to your printouts you don't. Because the last line output on starting runserver would be LiveReload request emitted.

Reload on templates and static files work without livereload-server's runserver but not reload on python files.

when i change css js py files the browser reloads automatically ..

OK. If you submit a PR I will look at it.