Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
Django: Bokeh.safely no es una función

Estaba tratando de incrustar un diagrama de bokeh en mi aplicación django. Seguí las instrucciones dadas en el sitio web de Bokeh y otra pregunta .

Recibo el siguiente error en la consola de mi navegador y no obtengo ningún resultado de gráfico:

 Uncaught TypeError: Bokeh.safely is not a function at HTMLDocument.fn (localhost/:15)

No soy un tipo de JS, pero Bokeh.safely está presente en el script generado por Bokeh. Adjunto el script generado al final:

Mi archivo views.py:

 from django.shortcuts import render from bokeh.plotting import figure from bokeh.resources import CDN from bokeh.embed import components def showGraph(request): arr = [1,4,9,16,25,36] y = [1,2,3,4,5,6] plot = figure() plot.line(arr, y) script, div = components(plot, CDN) return render(request, "data_collection/simple_chart.html", {"script": script, "div": div})

archivo simplechart.html:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Bokeh example</title> <link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.0.min.css"> <link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.0.min.css"> <script src="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.0.min.js"></script> <script src="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.0.min.js"></script> {{ script | safe }} </head> <body> {{ div | safe }} </body> </html>

Script generado por bokeh:

 (function(){ var fn = function(){ Bokeh.safely(function(){ var docs_json = {....json.....}; var render_items = [ {"docid": "27fe9292-3142-4617-b273-f9d932e47df3", "elementid": "7b2ef36e-a7d2-4a6b-88e6-186edecde6ca", "modelid": "741db3b0-26ce-45c1-86b4-d95394c7331f"}]; Bokeh.embed.embed_items(docs_json, render_items); }); }; if (document.readyState != "loading") fn(); else document.addEventListener("DOMContentLoaded", fn); })();
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Está cargando la versión 0.12.0 de BokehJS desde CDN en su plantilla simplechart.html , pero es casi seguro que está utilizando una versión más nueva de la biblioteca Python Bokeh. Las versiones de BokehJS y la biblioteca (Python) Bokeh deben coincidir.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!