Troubleshooting “Related Field has invalid lookup: icontains”

后端 未结 8 868
萌比男神i
萌比男神i 2021-01-31 06:33

I have the following models in models.py:

class ListinoTraduttore(models.Model):
        traduttore = models.ForeignKey(\'Traduttore\', related_name=         


        
相关标签:
8条回答
  • 2021-01-31 07:26

    This error, mostly occurs when you try to filter using a ForeignKey. I think the error is in the search_filelds. Check it. search_fields = ['traduttore__nome", "linguaDa", "linguaA"]. This two ForeignKey ("linguaDa", "linguaA") are the problem. Remove them. I think this helps.

    0 讨论(0)
  • 2021-01-31 07:30

    Have you tried adding the __fieldname on those Lingua references in the ListinoTraduttoreAdmin search_fields, like:

    class ListinoTraduttoreAdmin(admin.ModelAdmin):        
        list_display = ("traduttore", "linguaDa", "linguaA", "prezzoParola", "prezzoRiga", "scontoCat", "scontoFuzzy", "scontoRipetizioni")
        search_fields = ['traduttore__nome", "linguaDa__field1", "linguaA_field2"]
    
    0 讨论(0)
提交回复
热议问题