Search code examples
jquerypythondjangodjango-admindjango-grappelli

Django-grappelli add button visible in inline when add permissions are False


I'm not sure if its something I'm doing or if its a bug, but I have some strange behaviour with the add button in a TabularInline (django admin using grappelli). My inline class is:

class FieldInline(admin.TabularInline):
    model = models.Field
    classes = ('grp-collapse grp-closed',)

    fields = ('number', 'year', 'area')
    extra = 0

    def has_add_permission(self, request):
        return False

    def has_delete_permission(self, request, obj):
        return False

The add button appears when the inline formset is collapsed, but disappears when its open. I have tried digging through the jquerys involved, but I'm not very familiar with the language so I'm not too sure what I'm looking for.

Does anyone else get this behaviour? Is there an obvious solution?


Solution

  • This is a bug. I openend an issue for that on github as we use it as issue-tracker for Grappelli (https://github.com/sehmaschine/django-grappelli/issues/316).

    After taking a look at that: The visibility of the hidden button was an css-issue, fixed it with https://github.com/sehmaschine/django-grappelli/commit/da4d500c5e3b8f8dba5709b0378396131fad361d