• <legend id='jDTv7'><style id='jDTv7'><dir id='jDTv7'><q id='jDTv7'></q></dir></style></legend>

    <i id='jDTv7'><tr id='jDTv7'><dt id='jDTv7'><q id='jDTv7'><span id='jDTv7'><b id='jDTv7'><form id='jDTv7'><ins id='jDTv7'></ins><ul id='jDTv7'></ul><sub id='jDTv7'></sub></form><legend id='jDTv7'></legend><bdo id='jDTv7'><pre id='jDTv7'><center id='jDTv7'></center></pre></bdo></b><th id='jDTv7'></th></span></q></dt></tr></i><div id='jDTv7'><tfoot id='jDTv7'></tfoot><dl id='jDTv7'><fieldset id='jDTv7'></fieldset></dl></div>
    <tfoot id='jDTv7'></tfoot>
        <bdo id='jDTv7'></bdo><ul id='jDTv7'></ul>

        <small id='jDTv7'></small><noframes id='jDTv7'>

        未捕获的 ReferenceError:django 未定义

        时间:2023-09-07

      1. <tfoot id='O8bHi'></tfoot>
          <bdo id='O8bHi'></bdo><ul id='O8bHi'></ul>

            <tbody id='O8bHi'></tbody>
          <legend id='O8bHi'><style id='O8bHi'><dir id='O8bHi'><q id='O8bHi'></q></dir></style></legend>

            <small id='O8bHi'></small><noframes id='O8bHi'>

            <i id='O8bHi'><tr id='O8bHi'><dt id='O8bHi'><q id='O8bHi'><span id='O8bHi'><b id='O8bHi'><form id='O8bHi'><ins id='O8bHi'></ins><ul id='O8bHi'></ul><sub id='O8bHi'></sub></form><legend id='O8bHi'></legend><bdo id='O8bHi'><pre id='O8bHi'><center id='O8bHi'></center></pre></bdo></b><th id='O8bHi'></th></span></q></dt></tr></i><div id='O8bHi'><tfoot id='O8bHi'></tfoot><dl id='O8bHi'><fieldset id='O8bHi'></fieldset></dl></div>
                1. 本文介绍了未捕获的 ReferenceError:django 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在我的公式中使用带有几个 DateField 的管理小部件,但只有第一个可以正确显示小部件,而另一个我收到错误:

                  <块引用>

                  DateTimeShortcuts.js:205 Uncaught ReferenceError: django is not defined

                  (指示的行是:

                  django.jQuery(document).bind('keyup', function(event) {

                  )

                  这是我的模板头:

                  {% 加载管理媒体 %}<link rel="stylesheet" href="/static/css/main.css"/><script type="text/javascript" src="/admin/jsi18n/"></script><script type="text/javascript" src="/static/admin/js/core.js"></script><脚本类型="文本/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";</脚本><link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css"/><link rel="stylesheet" type="text/css" href="/static/admin/css/base.css"/><!-- <link rel="stylesheet" type="text/css" href="/static/admin/css/global.css"/>--><link rel="stylesheet" type="text/css" href="/static/admin/css/widgets.css"/>{{ form.media }}...

                  我的模型字段:

                  start_date = models.DateField()end_date = models.DateField()

                  还有我的表单类:

                  类 UserForm(ModelForm):start_date = forms.DateField(小部件=小部件.AdminDateWidget)end_date = forms.DateField(小部件=小部件.AdminDateWidget)元类:模型 = 用户

                  我猜这是某种渲染规则,但我完全糊涂了.欢迎任何帮助!

                  解决方案

                  django.jQuery定义在django/contrib/admin/static/admin/js/jquery.init.js 并依赖于 django/contrib/admin/static/admin/js/jquery.js.你需要直接在你的模板中加载那些js文件

                  <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script><script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>

                  或将这些文件包含在您的表单媒体中p>

                  同时检查 ModelAdminmedia 属性.

                  I'm trying to use the Admin Widgets with a couple of DateField on my formulary but only the first of them gets the widget displayed correctly, for the other one I get an error:

                  DateTimeShortcuts.js:205 Uncaught ReferenceError: django is not defined

                  (The line indicated is:

                  django.jQuery(document).bind('keyup', function(event) { 
                  

                  )

                  Here's my template head:

                  <head>
                  {% load adminmedia  %}
                  <link rel="stylesheet" href="/static/css/main.css" />
                  <script type="text/javascript" src="/admin/jsi18n/"></script>
                  <script type="text/javascript" src="/static/admin/js/core.js"></script>
                  <script type="text/javascript">
                      window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
                  </script>
                  <link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css"/>
                  <link rel="stylesheet" type="text/css" href="/static/admin/css/base.css"/>
                  <!-- <link rel="stylesheet" type="text/css" href="/static/admin/css/global.css"/> -->
                  <link rel="stylesheet" type="text/css" href="/static/admin/css/widgets.css"/>
                  {{ form.media }}...
                  

                  My model fields:

                  start_date = models.DateField()
                  end_date = models.DateField()
                  

                  And my form class:

                  class UserForm(ModelForm):
                      start_date = forms.DateField(
                          widget=widgets.AdminDateWidget
                          )
                      end_date = forms.DateField(
                          widget=widgets.AdminDateWidget
                          )
                      class Meta:
                          model = User
                  

                  I guess it some kind of rendering rule but I'm totally confused. Any help is welcome!

                  解决方案

                  django.jQuery is defined in django/contrib/admin/static/admin/js/jquery.init.js and relies on django/contrib/admin/static/admin/js/jquery.js. You need to load those js files in your template directly

                  <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
                  <script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
                  

                  Or include those files in your form media

                  Also check the media property of ModelAdmin.

                  这篇关于未捕获的 ReferenceError:django 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Facebook Like 按钮是如何工作的? 下一篇:R:将多个 html 小部件保存在一起

                  相关文章

                    • <bdo id='3dsVT'></bdo><ul id='3dsVT'></ul>
                  1. <small id='3dsVT'></small><noframes id='3dsVT'>

                    <legend id='3dsVT'><style id='3dsVT'><dir id='3dsVT'><q id='3dsVT'></q></dir></style></legend>
                    <tfoot id='3dsVT'></tfoot>

                      <i id='3dsVT'><tr id='3dsVT'><dt id='3dsVT'><q id='3dsVT'><span id='3dsVT'><b id='3dsVT'><form id='3dsVT'><ins id='3dsVT'></ins><ul id='3dsVT'></ul><sub id='3dsVT'></sub></form><legend id='3dsVT'></legend><bdo id='3dsVT'><pre id='3dsVT'><center id='3dsVT'></center></pre></bdo></b><th id='3dsVT'></th></span></q></dt></tr></i><div id='3dsVT'><tfoot id='3dsVT'></tfoot><dl id='3dsVT'><fieldset id='3dsVT'></fieldset></dl></div>