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

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

      • <bdo id='se4cy'></bdo><ul id='se4cy'></ul>

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

      1. 添加 list_filter 时,如何在 django modeladmin 更改列表中修复/设置列宽?

        How to fix/set column width in a django modeladmin change list table when a list_filter is added?(添加 list_filter 时,如何在 django modeladmin 更改列表中修复/设置列宽?)
          <tbody id='eQSuM'></tbody>

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

              <tfoot id='eQSuM'></tfoot>
              • <small id='eQSuM'></small><noframes id='eQSuM'>

                  本文介绍了添加 list_filter 时,如何在 django modeladmin 更改列表中修复/设置列宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在努力改进一个 django 项目中的 admin.py,虽然我并不完全对 list_diplay 中包含三个字段的表的输出方式感到兴奋,但至少它比只获得一个默认对象要好一列跨越整个页面的列表...

                  I'm working on improving the admin.py in a django project, and while I'm not totally jazzed about how the table was coming out with three fields in the list_diplay, at least it's better than just getting a default object list with one column spanning the whole page...

                  无论如何,我要问的是为什么:

                  Anyway, what I'm asking is why if this:

                  class FieldAdmin(admin.ModelAdmin):
                      list_display = ('name', 'label', 'standard',  )
                  

                  看起来像这样:

                  当我添加一个 list_filter 时,像这样:

                  When I add a list_filter, like this:

                  class FieldAdmin(admin.ModelAdmin):
                      list_display = ('name', 'label', 'standard',  )
                      list_filter = ['standard',]
                  

                  为什么会这样?

                  有没有办法让列重新增长以填充宽度,就像添加过滤器之前一样?我一直在阅读文档和谷歌搜索,但它似乎没有内置?我正在做的项目目前使用的是django 1,2,3,final.

                  Is there a way to get the columns to re-grow to fill the width like it was prior to adding the filter? I've been reading the docs and googling, but it doesn't seem built in? The project I'm working on is currently using django 1,2,3,final.

                  FWIW,导致这种情况的 css 在这里:

                  FWIW, the css that causes this is here:

                  .change-list .filtered table, .change-list .filtered .paginator, 
                  .filtered #toolbar, .filtered div.xfull {
                      margin-right: 160px !important;
                      width: auto !important;
                  }
                  

                  禁用宽度样式规范可以修复它,但如果有的话,我宁愿以 django 方式做事 - 我希望也许有一种方法可以从 FieldAdmin 类自定义过滤器视图?

                  disabling the width style specification fixes it, but I'd rather do things the django way if there is one - I was hoping maybe there's a way to customize the filter view from the FieldAdmin class?

                  推荐答案

                  你可能想参考这个:https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-模板

                  基本上,change_list.html 需要被覆盖.

                  basically, the change_list.html needs to be overridden .

                  你可以这样做:

                  templates/
                    admin/
                      app/
                        change_list.html
                  

                  您可以从 django/contrib/admin/templates/admin/

                  并按照您想要的方式更新 css.

                  and update the css the way you desire.

                  这篇关于添加 list_filter 时,如何在 django modeladmin 更改列表中修复/设置列宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)
                • <small id='Aol9y'></small><noframes id='Aol9y'>

                    <bdo id='Aol9y'></bdo><ul id='Aol9y'></ul>

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

                        <tfoot id='Aol9y'></tfoot>

                            <legend id='Aol9y'><style id='Aol9y'><dir id='Aol9y'><q id='Aol9y'></q></dir></style></legend>