• <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

        时间:2023-11-08
          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Django 中对 CheckboxSelectMultiple 选项进行分组 下一篇:在 django admin 中保存对象时出现 unicode 错误

                  相关文章

                • <legend id='XzCs9'><style id='XzCs9'><dir id='XzCs9'><q id='XzCs9'></q></dir></style></legend>
                • <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>