Problem Using Templates with Django


I am trying to use a template to style my panel app running on django app but I’m running into some issues. The panels I add to my template show up fine but none of the variables or custom html are rendered. To make the issue easier to replicate, I modified the example django2 project based directly off the template documentation. In the screenshot below I would expect to see the text included in my <p> tag and in the app_title variable. Am I implementing this wrong?


import panel as pn

from .sinewave import SineWave

template = """
{% extends base %}

<!-- goes in body -->
{% block postamble %}
<link rel="stylesheet" href="">
{% endblock %}

<!-- goes in body -->
{% block contents %}
{{ app_title }}
<p>This is a Panel app with a custom template allowing us to compose multiple Panel objects into a single HTML document.</p>
<div class="container">
  <div class="row">
    <div class="col-sm">
      {{ embed(roots.A) }}
    <div class="col-sm">
      {{ embed(roots.B) }}
{% endblock %}

def app(doc):
    sw = SineWave()

    tmpl = pn.Template(template)

    tmpl.add_variable('app_title', '<h1>Custom Template App</h1>')

    tmpl.add_panel('A', sw.param)
    tmpl.add_panel('B', sw.plot)

I am running panel 0.9.5, bokeh 2.0.0, and holoviews 1.13.2


Do you get any errors in the browser’s console?

No errors besides devtools stuff

I’ll have to investigate this more deeply, I’m not yet sure how templating interacts with the Django integration. This may end up needing fixes in bokeh itself.

Thanks for looking into it. Let me know if you need any more info about my setup or if I can help in any way.