QuerySet, Object has no attribute id - Django

前端 未结 4 738
死守一世寂寞
死守一世寂寞 2021-02-01 04:24

I\'m trying to fetch the id of certain object in django but I keep getting the following error Exception Value: QuerySet; Object has no attribute id. my function in views.py

4条回答
  •  天命终不由人
    2021-02-01 05:02

    The reason why you are getting the error is because at is a QuerySet ie: a list. You can do something like at[0].id or use get instead of filter to get the at object.

    Hope it helps!

提交回复
热议问题