pythondjangopython-3.xdashing

Unable to load template file for custom widget


I'm trying to create a custom widget(named Status) with django-dashing.
This custom widget is 99% copy-paste from libs own NumberWidget. I have js, html and css files in status/widgets/status and initiated in dashing-config.js

in the browser console(Chrome) i get following message: "widget Status does not exist". So i have created my own {templates}dashing/dashing.html and loaded css/js files manually. Now i have placeholder for the widget, no error messages in console and i see successfull ajax requests, but the widget body is empty.

So widgets html file is not loaded, but why?


Solution

  • After reverse engineering of Dashing.utils.js i found out that example dashboard.html from the docs is incomplete and templates block is missing. So full dashboard.html should be like:

    {% extends 'dashing/base.html' %}
    {% load staticfiles %}
    
    {% block stylesheets %}
    <link rel="stylesheet" href="{% static 'widgets/status/status.css' %}">
    {% endblock %}
    
    {% block templates %}
    <link rel="resource" type="text/html" href="{% static 'widgets/status/status.html' %}" data-widget="status">
    {% endblock %}
    
    {% block scripts %}
    <script type="text/javascript" src="{% static 'widgets/status/status.js' %}"></script>
    {% endblock %}
    
    {% block config_file %}
    <script type="text/javascript" src="{% static 'dashing-config.js' %}"></script>
    {% endblock %}