Bokeh integration in Django+Vue.js application

Hi all,

I am building a web application with Django managing the backend (using Django REST Framework) and Vue.js in the frontend. I would very much like to integrate bokeh into this setup, but I’m not sure how to go about it. I need bokeh to be able to accept variable data from the backend (e.g. generate an instance of a bokeh application with some numpy array as input) and be embedded into my Vue.js components.

  • I found examples for embedding bokeh in Django templates, but I’m missing a way to pass variable input (as far as I understood, the examples don’t offer that functionality).

  • I can’t find any examples or discussions about embedding bokeh in Vue.js components, I was hoping someone might have some thoughts on the matter.

Thank you all very much and all the best,

The repo is old but it can give you some hints

This is fantastic! Thank you so much.

Everything seems to be working fine when I just send a simple plot, but when I try to create an entire layout with widgets and interactions, pass it to the bokeh.embed.components function, and send the created script and div, I get an error in the console of my Vue app:

Uncaught Error: Model 'Select' does not exist. This could be due to a widget
                     or a custom model not being registered before first usage.

I’m not sure whether I’m using the components function wrong and perhaps my document requires the bokeh server because of the various interactions it includes, or if it’s something else entirely.

I guess I’ll try to programatically start a bokeh server from django and use the bokeh.embed.server_document function - I hope I’ll have more success with that.

If anyone thinks has a better idea I would be extremely thankful. Can’t wait to be able to fully integrate bokeh with Vue.

Thanks again and all the best!

I can’t seem to be able to solve this :sweat:
I tried to use the examples in the Embedding Bokeh Server as a Library section of the docs but I’m ending up with an absolute mess - I keep getting an error saying "There is no current event loop in thread ‘Thread-X’ ".
I also tried to simply run the app completely separately and then use the server_document function to embed it, but I had no luck with that either.

If anyone has any thoughts or ideas I would be extremely thankful.
Thank you and all the best :pray: