AttributeError-'RawQuerySet'对象没有属性'exclude'

时间:2019-01-22 09:15:24

标签: django django-models django-forms django-templates django-views

我使用原始查询是因为我想根据单个不同的列-Django选择唯一的行

context['reports'] =  TimesheetEntry.objects.raw('SELECT * FROM timesheet_entry t1 INNER JOIN ( SELECT timesheet_users_id, MAX(id) AS latest_id FROM timesheet_entry GROUP BY timesheet_users_id ) t2 ON t1.timesheet_users_id = t2.timesheet_users_id AND t1.id = t2.latest_id WHERE timesheet_is_running=False')
context['reports'] = context['reports'].exclude(pk=36)

这给我错误-

AttributeError - 'RawQuerySet' object has no attribute 'exclude'

我如何排除?或如何将以上RawQuerySet转换为QuerySet

0 个答案:

没有答案