Troubleshooting “Related Field has invalid lookup: icontains”

后端 未结 8 874
萌比男神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:23

    This worked for me.

    Search the field of the foreign key using my_related_object__first_attribute:

    search_fields = ('author__username', 'title')
    from models
    author = models.ForeignKey(User, on_delete=models.CASCADE,   related_name='blog_posts2')
    

提交回复
热议问题