Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

821
Vistas
How can I hide (not disable) in Django admin the action add model button in ModelAdmin list view?

I am aware of the following questions which are pretty different:

  • Django Admin - Disable the 'Add' action for a specific model
  • Disable link to edit object in django's admin (display list only)?

My question is a little different: how can I disable the action button in the model list view, but retain the add functionality and links for all other Django parts (for example OneToOne relations and inlines). The code:

@admin.register(Document)
class DocumentAdmin(admin.ModelAdmin):
    list_display = ("id", "name", "template", "file")
    fields = ["template", "name", "file"]

    def has_add_permission(self, request):
        return False

disables completely the add functionality of ModelAdmin (Django 3.2+, not tested in early versions).

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

A possibility is:

@admin.register(Document)
class DocumentAdmin(admin.ModelAdmin):
    list_display = ("id", "name", "template", "file")
    fields = ["template", "name", "file"]

    def has_add_permission(self, request):
        return ("add" in request.path or "change" in request.path)

This will allow to maintain the "/admin/<app>/<model>/add/" functionality, also in popup. The model list view will allow the model edit but it will not have the "add" button.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda