我正在尝试首次设置dashing-django。我已经能够启动并运行仪表板,但是无法向仪表板添加新的小部件。

我在dashing-config.js文件中添加了以下几行,该文件如下放置在静态目录中


  .. \ 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
    });


但是,当我在浏览器中检查javascript文件时,它没有反映任何更改。

所以我的问题是如何添加小部件以及应该将dashing-config.js放在哪里?

编辑:寻找快速答案的任何人
settings.py文件已根据建议进行了修改。

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

)

最佳答案

为了快速解决问题,请重新排序INSTALLED_APPS,以在'ddash'之前添加应用程序'dashing'

解释:django-dashing为您不提供默认配置提供了一个默认配置。如this post中所述,django.contrib.staticfiles应用程序(和collectstatic)搜索文件的顺序除其他因素外还取决于on the order in which the apps are included。问题可能出在您自己的应用程序之前包括破折号,这导致在您的应用程序之前找到默认配置。 Django文档在“ Static file namespacing”标题下没有提及这种令人困惑的行为。

实际的解决方案:幸运的是,破折号识别出了此问题,并为您提供了change the template file以及包含配置的位置的选项。

关于python - django-dashing没有正确设置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32864281/

10-12 18:18