I'm trying to achieve something apparently simple but I couldn't find any answer, neither on Google nor here. I have a Django model, something dead-simple:
class Shipment(models.Model):
id = models.AutoField(primary_key=True)
transaction = models.ForeignKey(Transaction)
I would like to be able to search in my Shipment Admin page by transaction.id. To clarity, I want this (this code obviously doesn't work):
class ShipmentAdmin(admin.ModelAdmin):
list_display = ('id', 'transaction')
search_fields = ['id', 'transaction.id']
This can't work cause transaction.id does not name a field. Any idea? By "search" I mean be able to insert my transaction id inside the search box of the Shipment Admin page, press "search" and automatically retrieve appropriate transactions.