models.py
class Supplier(models.Model):
name = models.CharField(blank=True, max_length=50,)
city = models.CharField(blank=True, max_length=50)
email = models.CharField(blank=True, max_length=50)
class Product(models.Model):
supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
description = models.CharField(blank=True, max_length=100)
DDT = models.FileField(upload_to="DDT/%Y/%m/%d")
fattura = models.FileField(upload_to="DDT/%Y/%m/%d")
admin.py
@admin.register(Supplier)
class SupplierModelAdmin(admin.ModelAdmin):
model = Supplier
@admin.register(Product)
class ProductModelAdmin(admin.ModelAdmin):
model = Product
list_display = ['supplier']
search_fields = [ 'supplier']
when i search for a supplier , django return an error :
Related Field got invalid lookup: icontains