Search code examples
pythondjangodashing

django-dashing not getting set up properly


I'm trying to set up dashing-django for the first time. I have been able to get the dashboard up and running but I'm unable to add a new widget to the dashboard.

I have added the following lines in the dashing-config.js file,the file is placed in the static directory as follows

..\dash1\dash1\static

   var myDashboard = new Dashboard();
    myDashboard.addWidget('custom_widget', 'Number', {
        getData: function () {
            var self = this;
            $.get('custom_widget', function(data) {
                $.extend(self.data, data);
            });
        },
        interval: 300
    });

but when i inspect the javascript file in the browser it doesnt reflect any of the changes.

so my question is how to add widgets and where should i place the dashing-config.js ?

Edit : for any one looking for the quick answer the settings.py file was modified as suggested.

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'dash1', ---- order matters <your app>
    'dashing', --- default dashing

)

Solution

  • As a quick hack to get it working: reorder INSTALLED_APPS to add your app 'ddash' before 'dashing'.

    To explain: django-dashing provides a default config for the case that you don't provide one. As explained in this post, the order in which the django.contrib.staticfiles app (and collectstatic) searches for files depends amongst other things on the order in which the apps are included. The problem is likely that you include dashing before your own app, which leads to the default config to be found before yours. The Django docs don't fail to mention this confusing behavior under the heading of “Static file namespacing”.

    Real solution: Fortunately, dashing recognizes this problem and gives you the option to change the template file and with it from where the config is included.