Search code examples
pythonpython-3.xdjangodjango-admindjango-1.9

How to remove the save and continue editing button in django-admin in django 1.9?


I have attempted all the solutions listed in In Django admin, how can I hide Save and Continue and Save and Add Another buttons on a model admin? and that post was from a few years ago, and I can't find anything about how to disable those buttons. Due to custom saving, the Save And Continue Editing button causes an error. Is there any way to disable it in the current version of django? Constraints: - Cannot put app before django.contrib.admin - I need to only disable it for one form. - I have a custom form for creation, and it has a custom save method (it's an account creation)


Solution

  • You can just hide the button (the underlying functionality will still be there, but the button will not be visible).

    This should work

    from django.contrib import admin
    
    class MyModelAdmin(admin.ModelAdmin):
        ...
    
        class Media:
            css = {
                'all': ('some/path/to/css/disable_save_and_continue_editing_button.css')
            }
    

    disable_save_and_continue_editing_button.css

    input[name="_continue"] {
      display: none;
    }