Django query Advanced

22 views
Skip to first unread message

Hélio Miranda

unread,
Sep 26, 2013, 11:54:43 AM9/26/13
to django...@googlegroups.com
I am trying a query like this:

result = json.dumps([a.get_json() for a in Player.objects.filter((Q(name=namepost) | Q(surname="Coimbra")))])
   return HttpResponse (result, content_type = 'application / json')
But it gives me the following error: Not a query object: (AND: ('surname', 'Coimbra'), ('name', u'Rui ')). Did you intend to use key = value?
get_json def (self):
      return {
        'name': self.name,
        'surname': self.surname,
        'country': [{'name': b.name} for b in self.country]
       }

If I do well

result = json.dumps([a.get_json() for a in Player.objects.filter(name=namepost)])

works well

What am I doing wrong? Someone can help me?

Reply all
Reply to author
Forward
0 new messages