1. Jesper Nøhr
  2. django-piston
Issue #166 new

Fields missing in response

FrEaKmAn
created an issue

Hello

Below I included my handler. Problem is that when offices_count > 0, the field is included in response but if its equal 0, its not. Normal?

{{{

!python

class AgencyHandler(BaseHandler): allowed_methods = ('GET') fields = ('id', 'name', 'offices_count') exclude = () model = Agency

def read(self, request):
    q = Agency.objects.filter(status='active')
    q = q.annotate(offices_count=Count('office'))
    return q

}}}

response

{{{

!text

[ { "id": 1, "name": "Foo"
"offices_count": 10, }, { "id": 2, "name": "Bar"
} ]

}}}

Comments (2)

  1. Log in to comment