How to create search field in django admin

how-to-create-search-option-in-django-3

Hello World, Welcome to ProjectsPlaza.com. Today we will discuss how to create a search field in the Django admin panel. I am using Django 3. Django is a very powerful MVT (Model View Template) web Framework built with python. It comes with lots of features.

For creating a search option in the Django admin panel, We just need to activate the search features. If you have not created an admin panel in Django then please have a look at the following tutorial 👇.

How to create an admin panel in Django 3


Activate the search feature in the admin panel

  • Please open your_app/admin.py
  • Suppose you have created a Video Model and you want to make video title searchable in the admin panel.
  • Create the following class before register your Video Model in the admin.
class VideoAdminModel(admin.ModelAdmin):
    search_fields=('title',)
  • Register Video Model with this class.
  • admin.site.register(Video,VideoAdminModel)

After applying these changes, you will see the search option above the videos list like following.

search-option-in-django-admin

1 thought on “How to create search field in django admin”

  1. Pingback: How to create search field in django admin – ProjectsPlaza – Php Projects | Laravel Projects

Leave a Reply