Remove “add another” in Django admin screen

后端 未结 10 586
孤独总比滥情好
孤独总比滥情好 2020-12-05 13:34

Whenever I\'m editing object A with a foreign key to object B, a plus option \"add another\" is available next to the choices of object B. How do I remove that option?

10条回答
  •  温柔的废话
    2020-12-05 14:19

    I'm using Django 2.x and I think I found best solution, at least for my case.

    The HTML file to the "Save and Add Another" button is on your_python_installation\Lib\site-packages\django\contrib\admin\templates\admin\subtmit_line.html.

    1. Copy that html file and paste to your project like so your_project\templates\admin\submit_line.html.
    2. Open it and comment/delete the button code as desired:

    {#{% if show_save_and_add_another %}{% endif %}#}

    I know this problem is already answered. But maybe someone in the future have a similar case with me.

提交回复
热议问题