我正在尝试这样的查询:
json.dumps result = ([a.get_json () for a in Player.objects (Q (name = namepost, surname = "Coimbra"))])
return HttpResponse (result, content_type = 'application / json')
但是它给了我以下错误: 不是查询对象:(AND:('surname','Coimbra'),('name',u'Rui'))。您打算使用key = value吗?
我的课上有这个
get_json def (self):
return {
'name': self.name,
'surname': self.surname,
'country': [{'name': b.name} for b in self.country]
}
如果我做得好
json.dumps result = ([a.get_json () for a in Player.objects.filter (name = namepost)])
运作良好
我做错了什么?有人可以帮帮我吗?