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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…