Django: invalid literal for int() with base 10

后端 未结 6 769
时光说笑
时光说笑 2020-12-15 03:14

I am new to Django and trying to pass an author\'s name to a view and filter out quote objects based on the author\'s name. here are the codes:

models.py

<         


        
6条回答
  •  不知归路
    2020-12-15 03:26

    aquotelist = Quote.objects.filter(author__author_name__exact = name)
    

    Try changing the corresponding line to the above. The way you have it now, you are matching author to the given name, but author is probably considered by its ID here, definitely not by its author_name. The format is as follows:

    Quote.objects.filter([model]__[field]__exact = [whatever])
    

提交回复
热议问题