[Fixed]-Django raw_id_fields widget not showing search icon

35👍

I’ve found the problem thanks to this message in django-users.

I had to register in the admin the model to which the ForeignKey points to.

The search doesn’t work without that.

2👍

In the admin.py file add:

admin.site.register(YourModel)

This did the trick, Where YourModel is the model to be displayed with the magnifying glass

2👍

Hi encounter the same issue but reason’s a bit different.

To integrate the User and UserGroup with another app’s admin (e.g. some_app)

I added below code to some_app/admin.py

class ProxyUser(User):
    class Meta:
        proxy = True
        verbose_name = User._meta.verbose_name
        verbose_name_plural = User._meta.verbose_name_plural


class ProxyGroup(Group):
    class Meta:
        proxy = True
        verbose_name = Group._meta.verbose_name
        verbose_name_plural = Group._meta.verbose_name_plural

admin.site.unregister(Group)
admin.site.unregister(User)
admin.site.register(ProxyGroup)
admin.site.register(ProxyUser, UserAdmin)

I think the unregister(...) will affect the other app’s admin Globally!

That’s another cause of missing search icon.

👤C.K.

Leave a comment