A
A
AinzO2021-08-15 09:56:05
Django
AinzO, 2021-08-15 09:56:05

Is there any way to configure the Django admin panel so that the database can be searched through it?

Search should be on different columns

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2021-08-15
@AinzO

# admin.py
class LectModel(admin.ModelAdmin):
   ...
    search_fields = ['title', 'discipline__name'] # Здесь указать нужные поля
    # discipline__name - поиск по внешнему ключу где __name - название поля связанной таблицы. 

...
admin.site.register(Discipline, DisModel)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question