Incorporating plotly graphs in Django (websockets or django-plotly-dash)

I have an existing Django project which is a front end to my home automation and astronomy dome. See attached screen shot.

As part of the astronomy setup, I have a 3rd party weather station which overwrites a json file with environmental data every 15 secs. This file updates a pandas dataframe keeping the last 48 hours of data. From this dataframe I have used plotly to make a graph and embedded it into the Django project. The graph also shows the level (red dotted line) at which the dome will automatically close (not relevant for temperature, but very relevant for rain!) The background colours represent ‘division lelvels’ of environmental data (again not particularly relevant for temp but quite relevant for clouds e.g. green=clear, amber=cloudy and red=overcast).

The next stage is to a) make the graph update in real time and b) put a drop down box on the webpage to provide the ability to change the data source (within the dataframe) e.g. select clouds, light, rain, wind etc.

It seems to me that django-plotly-dash would be ideal. My problem is that DPD downgrades Django, channels and daphne. My project runs in 5 Docker containers (web, celery, celery best, NGINX and REDIS). It uses bootstrap5, channels, websockets, daphne and celery. All dependencies are latest or near latest versions. I just can’t face downgrading and debugging code for such a complex project especially when it involves so many container restarts. Although I have been coding on and off for 40+ years I am very much an amateur and coding is purely a means to an end (i.e. a working website).

I have looked at DPD’s code to see if there is anything I can do to update it. It is obvious that a huge amount of work has gone into DPD, it is very impressive. It is equally obvious that it is well beyond my coding abilities to even attempt to offer an update.

So the question…………

  1. can / should I simply use channels and websockets (technology I am familiar with) to make the graph selectable and update in real time ?
  2. or does anyone know if DPD is likely (anytime soon) to be updated to work with later versions of daphne, channels and Django ?
  3. I have time to assist beta testing this but not enough skill to code it.

The current constraints are Django < 4.0 and channels < 3.0 and most of this is due to deprecated functionality due to name changes. For example, ‘url’ is not in ‘django.confs.urls’ any more. There is this github issue - any and all pull requests most welcome - and it will probably be addressed in the near future when it becomes a blocker for someone.

As for daphne, as it was for a long time not production ready (and I’m not what the current status of the code and associated documentation is) we’ve preferred to use other ASGI servers in our deployments - uvicorn works well, for example. And at some point in the past there was some work on removing daphne from the stack as it turned up even if you didnt want it and had a lot of dependency issues, although it is not as bad as it used to be.

Thank you very much for taking the time and trouble to reply, Mark. I really appreciate it.

It is a stopper for me as I really don’t want to potentially ‘break’ something I have developed (off and on) for the last 2 years by going back to older versions.

I can’t remember why I chose daphne, probably because (at the time) it had the best YouTube “development to production Daphne → NGINX ” video. As I say, I can’t remember. I don’t want to change as I don’t want to unpick something which works for me.

As suggested by a contributor to stackexchange, I had already forked your repository and taken some steps to recode with my versions of django, channels and daphne. All with a view to making a pull request. I spotted the urls issue straight off but after that I was very soon out of my depth. I think maybe one of the issues was I was running it with your very comprehensive demo and was never sure if the errors I was finding were in the demo or DPD.

I would be prepared to spend some time trying again with the DPD code, if you were prepared to give me some ad hoc guidance when I got stuck. I completely understand if that is not possible.

Thanks once again (for the reply and all the effort that has gone into DPD).
Ian