我正在查询数据库:
def get_queryset(self):
queryset = {'test_suites': TestSuite.objects.filter(user__user_id=self.request.user.id),
'username': self.request.user)}
return queryset
来自此模型字段:
from django.contrib.auth.models import User
class TestSuite(models.Model):
user_id = models.ForeignKey(User, on_delete=models.CASCADE)
...
...
User
是Django的auth User模型。我正在尝试过滤数据
从TestSuite通过其用户ID。不断收到错误消息:Cannot resolve keyword 'user' into field
更新:
def get_queryset(self):
queryset = {'test_suites': TestSuite.objects.filter(user=self.request.user),
'username': self.request.user}
return queryset
当前回溯显示:Cannot resolve keyword 'user' into field.
答案 0 :(得分:0)
可能是因为您的视图上有一个额外的')':
'username': self.request.user)}