Obviously you will be searching in related table. 

So if you have models.py like:

class Author(models.Model):
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)

class Book(models.Model):
    title = models.CharField(max_length=200)
    author = models.ForeignKey(Author)

Then in your admin.py for book:

    search_fields = (
        'title', 'author__first_name',  'author__last_name', )

HTH

On Tuesday, 5 October 2021 at 22:37:22 UTC+2 iyanuol...@gmail.com wrote:

> Good day, I would like to use the list_display and search_fields functions 
> in one table on the Django admin page to display and search for a field in 
> another table. Could I please get any pointers on how to go about this? 
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7db8ff9d-2cde-4647-9490-22561cd98bffn%40googlegroups.com.

Reply via email to