talpor / django-dashing

django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing
BSD 3-Clause "New" or "Revised" License
731 stars 108 forks source link

Unable to avoid loading default widgets #82

Closed romanrdgz closed 6 years ago

romanrdgz commented 6 years ago

I have followed the steps in order to create my own widget. But no matter what I do, default widgets are being loaded instead. If I check my Django debug server output, my own dashing-config.js is being loaded because I'm doing a GET request there that is happening according to the log, but I assume that later the default dashing-config.js is being loaded.

I'm working with Python 3.5.2 with Django 2.0.

My widgets.py:

from dashing.widgets import NumberWidget
class InterferenceCountWidget(NumberWidget):
    title = 'Detected interferences'
    value = 0

    def get_title(self):
        return self.title

    def get_value(self):
        return self.value

My dashing-config.js (situated in /myapp/myapp/static/dashing/dashing-config.js):


var dashboard = new Dashboard();

dashboard.addWidget('interference_count_widget', 'Number', {
    getData: function () {
        var self = this;
        $.get('/interference_count/', function(data) {
           self.data = data;
           dashboard.publish('interference_count_widget/render');
        });
        dashboard.publish('interference_count_widget/render');
    }
});

My urls.py:

from django.contrib import admin
from django.urls import path
from dashing.utils import router
from .widgets import InterferenceCountWidget

router.register(InterferenceCountWidget, 'interference_count_widget')

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(router.urls)),
    path('interference_count/', InterferenceCountWidget.as_view(), name='interference_count_widget')

Default settings.py but for including dashing in INSTALLED_APPS.

What am I missing here? It seems non trivial to avoid loading default demo widgets...

mtdb commented 6 years ago

The default path for the config file is {% static 'dashing-config.js' %} you have {% static 'dashing/dashing-config.js' %} also you can replace the config_file block in your template (http://django-dashing.readthedocs.io/en/latest/getting-started.html#template-file)

romanrdgz commented 6 years ago

Finally achieved it by adding this to my settings.py: STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ]