【问题标题】:Handlebar changes are not affecting - Python Django车把变化不影响 - Python Django
【发布时间】:2017-11-30 06:40:22
【问题描述】:

我是 django 和 python 初学者。 Django 应用程序作为守护进程托管在 apache 网络服务器中。 我正面临使用 java 脚本在 django 中呈现 URL 的问题。

在我的车把(html 模板)中,我做了一些 html 更改,但不幸的是,更改并没有体现出来。

流程就像, 当从浏览器调用和 URL 时,我的 urls.py 将调用 views.py,在 views.py 中,Node_edit.html 将被渲染。

Node_edit.html 将包含车把。

对不起,我的英语不好。

views.py

@csrf_protect

def hierarchyNode_new(request, parentNode_id=None):

parentNodeObject = None

if(parentNode_id):

    context = {
        "parentNode_id": parentNode_id
    }
    return render(request, 'test/Node_edit.html', context)

Node_edit.html

{% load staticfiles %}

    var assetList =
    [
       //applying the html template
       { url: '{% static "test/handlebar/Node.handlebar" %}', loadHandler: templateLoaderFunction, name: 'Node_edit'        },

    ]
    $(document).ready( function () {

        debug.log("load complete")

        registerHandlebarHelpers()

        // create templates hash if not already present
        Handlebars.templates = Handlebars.templates || {};

        console.log(assetList);

        chainLoadAssets(assetList, function()

        {

            var hierarchyNodeEditor = new HierarchyNodeEditor(

                "{% url 'test:index' %}",
                "{% url 'test:Node_list' %}",
                {% if Node %}
                "{% url 'test:Node_jsonbase' %}",
                {% else %}
                "{% url 'test:Node_new' %}",
                {% endif %}
                "{{ Node.id }}",
                "{{ parentNode_id }}",
                "{{ csrf_token }}"
            )
            NodeEditor.start()
        })

    })

</script>

Node.handlebar

      <div class="col-sm-7">
        <input type="checkbox" id="Node_edit_display" checked="checked" (Trying to make check box checked)
            {{#ifeq json.display "1" }}
                checked
            {{/ifeq}}
        />
      </div>

注意:即使我删除了那个车把。但是页面仍在渲染。但是问题是我的更改在浏览器中没有生效

我清除了浏览器缓存并重新启动了 apache。

疑问:

还有其他缓存,我应该清除吗?

这是我的舞台服务器。 但是,这个问题并没有出现在我的开发服务器中。

在阶段服务器中应用更改时面临此问题。

我仍然坚持这一点。任何帮助将不胜感激。

【问题讨论】:

    标签: javascript python html django django-cache


    【解决方案1】:

    我在这里找到了答案https://docs.djangoproject.com/en/2.0/ref/contrib/staticfiles/

    python manage.py collectstatic应该可以解决问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-08
      相关资源
      最近更新 更多