Bokeh, Ajax, and Django

Hi,

I am wondering if there is a working example similar to this one but for Django:

In particular, I have problems to implement the (apparently needed) crossdomain feature.

Thanks

Cross domain is
usuall y a case of configuring your
django pro cess correctly to
accept requests from where ver
your bokeh request is coming from.

···

On 7/21/16 5:26 AM, Artur Scholz wrote:

Hi,

    I am wondering if there is a working example similar to this one

but for Django:

    In particular, I have problems to implement the (apparently

needed) crossdomain feature.
Thanks

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected].

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/e7d13e2e-2ac0-427f-b410-5fc078bf0307%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/e7d13e2e-2ac0-427f-b410-5fc078bf0307%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

https://github.com/bokeh/bokeh/blob/master/examples/howto/ajax_source.py

Thanks Sarah for the hint.
Indeed there is middleware for Django to deal with crossdomain (e.g. see answer here http://stackoverflow.com/questions/20354135/django-view-with-cross-domain-ajax).
But I found a much simpler way that works for my use case:

source = AjaxDataSource(method=‘GET’,data_url=‘http://localhost:8000/view2d/data/’,
polling_interval=1000)

def data(request):
response = JsonResponse(dict(x=[10],y=[10]))
response[“Access-Control-Allow-Origin”] = “*”
response[“Access-Control-Allow-Methods”] = “GET, POST, OPTIONS”
response[“Access-Control-Max-Age”] = “1000”
response[“Access-Control-Allow-Headers”] = “Content-Type”
return response

``

Yay!

···

On 7/21/16 3:03 PM, Artur Scholz wrote:

Thanks Sarah for the hint.

    Indeed there is middleware for Django to deal with crossdomain

(e.g. see answer here
).
But I found a much simpler way that works for my use case:

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected].

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/16b72699-038c-4dfa-8b78-d01ab32aef22%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/16b72699-038c-4dfa-8b78-d01ab32aef22%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

http://stackoverflow.com/questions/20354135/django-view-with-cross-domain-ajax

source = AjaxDataSource(method=‘GET’,data_url=‘’,

                                    polling_interval=1000)

          ....

          def data(request):  

                response = JsonResponse(dict(x=[10],y=[10]))  

                response["Access-Control-Allow-Origin"] = "*"

                response["Access-Control-Allow-Methods"] =                 "GET,

POST, OPTIONS"

                response["Access-Control-Max-Age"] = "1000"

                response["Access-Control-Allow-Headers"] = "Content-Type"

                return
            response

``

http://localhost:8000/view2d/data/