Search code examples
pythondjangodjango-grappellidjango-autocomplete-light

Using django-autocomplete-light in grappelli in a stackedinline form


I'm trying to use django-autocomplete-light in a grappelli admin page within a StackedInline.

When used on fields in the main model, autocomplete-light fields work perfectly fine.

enter image description here

However in inlines they are non-functional. All I get is a gray X, that doesn't remove the model, and no field to enter text into:

enter image description here

And in dynamically added inlines, I can't even click into the field!:

enter image description here

My code:

In admin.py

class ServiceInline(MembershipInline):
    model = models.Service
    form = forms.MembershipInlineFormFactory(models.Service)

In forms.py

class ServiceAutocompleteForm(autocomplete_light.ModelForm):
    class Meta:
        fields='__all__'
        model = models.Service

        autocomplete_fields  = ['person','position']

Solution

  • So it turns out this is an issue with the generated CSS, where a float in grappelli is covering the actual autocomplete inputs. This can be fixed with the following CSS rule (as long as this is included in a file used by the admin site):

    .autocomplete-light-widget {
      z-index:10;
    }