@csrf_exempt
def ziggy_submissions(request, username):
    data = {'message': _(u"Invalid request!")}
    status = 400
    form_user = get_object_or_404(User, username__iexact=username)
    if request.method == 'POST':
        json_post = request.body
        if json_post:
            # save submission
            # i.e pick entity_id, instance_id, server_version, client_version?
            # reporter_id
            records = ZiggyInstance.create_ziggy_instances(
                form_user, json_post)

            data = {'status': 'success',
                    'message': _(u"Successfully processed %(records)s records"
                                 % {'records': records})}
            status = 201
    else:
        # get clientVersion and reportId
        reporter_id = request.GET.get('reporter-id', None)
        client_version = request.GET.get('timestamp', 0)
        if reporter_id is not None and client_version is not None:
            try:
                cursor = ZiggyInstance.get_current_list(
                    reporter_id, client_version)
            except ValueError as e:
                status = 400
                data = {'message': '%s' % e}
            else:
                status = 200
                data = [record for record in cursor]
    return HttpResponse(json.dumps(data), status=status)
Test iterating over empty results.
dataset/ETHPy150Open kobotoolbox/kobocat/onadata/apps/logger/views.py/ziggy_submissions--crossover with--dataset/ETHPy150Open hozn/stravalib/stravalib/tests/functional/test_result_iterator.py/ResultIteratorTest.test_empty