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 👇.
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.
After applying these changes, you will see the search option above the videos list like following.