【发布时间】:2022-01-26 18:42:54
【问题描述】:
尝试将对象从 False 更新为 True 时出现此错误。这是我的代码:
class ListNoti(LoginRequiredMixin,ListView):
raise_exception = True
model = Notifications
template_name = 'notifications/notifications.html'
def get_context_data(self, **kwargs):
data = super(ListNoti,self).get_context_data(**kwargs)
data['noti'] = Notifications.objects.filter(receiver=self.request.user,is_seen=False).order_by('-date').update(is_seen=True)
return data
.update(is_seen=True) 引发此错误TypeError at /notification/ 'int' object is not iterable
【问题讨论】:
-
在
order_by之前移动update(is_seen=True) -
Ahtisham 试过但没用
-
检查它是否在没有 order_by 的情况下工作
-
Ahtisham 在发布问题之前我都试过了。没用。
标签: python-3.x django django-views