Remove "add another" in Django admin screen

django, django-admin, python

Solution

DEPRECATED ANSWER

Django has since made this possible.

Have you considered instead, using CSS to simply not show the button? Maybe that's a little too hacky.

This is untested, but I'm thinking...

`no-addanother-button.css`

#_addanother { display: none }

`admin.py`

class YourAdmin(admin.ModelAdmin):
    # ...
    class Media:
        # edit this path to wherever
        css = { 'all' : ('css/no-addanother-button.css',) }

Django Doc for doing this -- Media as a static definition

Note/Edit: The documentation says the files will be prepended with the MEDIA_URL but in my experimentation it isn't. Your mileage may vary.

If you find this is the case for you, there's a quick fix for this...

class YourAdmin(admin.ModelAdmin):
    # ...
    class Media:
        from django.conf import settings
        media_url = getattr(settings, 'MEDIA_URL', '/media/')
        # edit this path to wherever
        css = { 'all' : (media_url+'css/no-addanother-button.css',) }

Problem

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? I configured a user without rights to add object B. The plus sign is still available, but when I click on it, it says "Permission denied". It's ugly. I'm using Django 1.0.2

Original source

Related problems