• <tfoot id='pVmde'></tfoot>
    <legend id='pVmde'><style id='pVmde'><dir id='pVmde'><q id='pVmde'></q></dir></style></legend>

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

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

        自定义 django 的管理员以具有依赖的选择字段

        时间:2023-11-08

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

          1. <legend id='IoOOa'><style id='IoOOa'><dir id='IoOOa'><q id='IoOOa'></q></dir></style></legend>

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

                  <tfoot id='IoOOa'></tfoot>
                  本文介绍了自定义 django 的管理员以具有依赖的选择字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I am new in django , I am developing admin panel first for my site. I need to have dependent select fields, so that after selecting country, user will be able to select city. I want that when I select country then cities of that country options load in city select box but I don't know how to customize django admin. I have done so in JS, using AJAX and PHP. So I know how to do it manually but don't know how to use ajax in django and how to customize it.

                  On some other questions I read that one should read, django documentation, so I tried to read and find at admin documentation but couldn't found way to customize django admin panel. Do I need to customize full page for those select boxes? Or please tell that how can I add some jquery code to it so that I can do it via JS?

                  解决方案

                  You probably want to use the feature Grouped Selects in django smart selects. From the README:

                  If you have the following model:

                  class Location(models.Model)
                      continent = models.ForeignKey(Continent)
                      country = models.ForeignKey(Country)
                  

                  And you want that all countries are grouped by the Continent and that Groups are used in the select change to the following:

                  from smart_selects.db_fields import GroupedForeignKey
                  
                  class Location(models.Model)
                      continent = models.ForeignKey(Continent)
                      country = GroupedForeignKey(Country, "continent")
                  

                  这篇关于自定义 django 的管理员以具有依赖的选择字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Django:StackedInline 的更友好的标题,用于通过模型自动生成? 下一篇:添加 list_filter 时,如何在 django modeladmin 更改列表中修复/设置列宽?

                  相关文章

                  <small id='1k2NK'></small><noframes id='1k2NK'>

                  <i id='1k2NK'><tr id='1k2NK'><dt id='1k2NK'><q id='1k2NK'><span id='1k2NK'><b id='1k2NK'><form id='1k2NK'><ins id='1k2NK'></ins><ul id='1k2NK'></ul><sub id='1k2NK'></sub></form><legend id='1k2NK'></legend><bdo id='1k2NK'><pre id='1k2NK'><center id='1k2NK'></center></pre></bdo></b><th id='1k2NK'></th></span></q></dt></tr></i><div id='1k2NK'><tfoot id='1k2NK'></tfoot><dl id='1k2NK'><fieldset id='1k2NK'></fieldset></dl></div>
                1. <legend id='1k2NK'><style id='1k2NK'><dir id='1k2NK'><q id='1k2NK'></q></dir></style></legend>
                2. <tfoot id='1k2NK'></tfoot>
                    • <bdo id='1k2NK'></bdo><ul id='1k2NK'></ul>