• <tfoot id='6zPPJ'></tfoot>

    • <bdo id='6zPPJ'></bdo><ul id='6zPPJ'></ul>

    <legend id='6zPPJ'><style id='6zPPJ'><dir id='6zPPJ'><q id='6zPPJ'></q></dir></style></legend>

    <i id='6zPPJ'><tr id='6zPPJ'><dt id='6zPPJ'><q id='6zPPJ'><span id='6zPPJ'><b id='6zPPJ'><form id='6zPPJ'><ins id='6zPPJ'></ins><ul id='6zPPJ'></ul><sub id='6zPPJ'></sub></form><legend id='6zPPJ'></legend><bdo id='6zPPJ'><pre id='6zPPJ'><center id='6zPPJ'></center></pre></bdo></b><th id='6zPPJ'></th></span></q></dt></tr></i><div id='6zPPJ'><tfoot id='6zPPJ'></tfoot><dl id='6zPPJ'><fieldset id='6zPPJ'></fieldset></dl></div>
    1. <small id='6zPPJ'></small><noframes id='6zPPJ'>

        如何在 Django Admin 中使用 can_add_related

        How to use can_add_related in Django Admin(如何在 Django Admin 中使用 can_add_related)
          <tbody id='d1IJa'></tbody>

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

                <legend id='d1IJa'><style id='d1IJa'><dir id='d1IJa'><q id='d1IJa'></q></dir></style></legend><tfoot id='d1IJa'></tfoot>
                • 本文介绍了如何在 Django Admin 中使用 can_add_related的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在这里阅读了有关 can_add_related 功能:https://code.djangoproject.com/ticket/9071

                  I've read about the can_add_related feature here: https://code.djangoproject.com/ticket/9071

                  我试过这样使用它:

                  def get_form(self, request, obj=None, **kwargs):
                      self.fields['person'].can_add_related = False
                      return super(OperationAdmin, self).get_form(request, obj, **kwargs)
                  

                  但这会引发 TypeError,我不知道如何解决.

                  But this throws a TypeError and I don't know how to solve this.

                  有人能指出正确的方向吗?

                  Can someone point me in the right direction?

                  谢谢.

                  推荐答案

                  这可能来晚了.但供其他观众参考,

                  This is probably coming in late. But for other viewers reference,

                  def get_form(self, request, obj=None, **kwargs):
                      form = super(ProductAdmin, self).get_form(request, obj, **kwargs)
                      form.base_fields['category'].widget.can_add_related = False
                      return form
                  

                  这篇关于如何在 Django Admin 中使用 can_add_related的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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中的另一个文件中查找一个文本文件的条目)
                • <legend id='XzCs9'><style id='XzCs9'><dir id='XzCs9'><q id='XzCs9'></q></dir></style></legend>
                    <tbody id='XzCs9'></tbody>

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

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

                        <tfoot id='XzCs9'></tfoot>

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