Custom field for search in the Django admin


Django tip:

search_fields sets which model fields will be searched when a search is performed in the Django admin.

You can also perform a related lookup on a ForeignKey or ManyToManyField with the lookup API "follow" notation (double underscore syntax):

@admin.register(Child)
class ChildAdmin(admin.ModelAdmin):
    search_fields = ['parent__name']