I have foreign key field with multiple items and it's really hard to find needed values.
Is there any solution to add search to admin's raw_id_fields popup? Or any alternative from core django package?
If there is no solution I'll use this one (https://github.com/yourlabs/django-autocomplete-light) but I want to avoid external dependencies.
Suppose you have two models Book
and Publisher
and you have
class Book(models.Model):
title = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
Then in your admin.py you have to create a custom admin class for Publisher if you haven't already done so.
class Publisher(admin.ModelAdmin):
...
search_fields = ('name','address','city')
Now in the raw_id_field popup for Book model instances in the admin, you will see that a search box appears (this is so in django 1.9 at any rate)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With