How to add custom search box in Django-admin?

cant reply due to low karma..

but don't forget to register the Admin Model too, like

admin.py

from django.contrib import admin
from .models import *

admin.site.register(Photo, PhotoAdmin)

Use the search_fields attribute of the ModelAdmin:

class PhotoAdmin(admin.ModelAdmin):
    ...
    search_fields = ['name', 'description', 'user__related_fieldname','keyword', ]

When you write:

admin.site.register([Photo, PhotoAdmin])

you register in admin two models: Photo and PhotoAdmin, you must register Model and ModelAdmin for it, like this:

admin.site.register(Photo, PhotoAdmin) 

Tags:

Python

Django