From cf551487f4e967165dcf10b30464b30fad7c2b92 Mon Sep 17 00:00:00 2001 From: MattBlack85 Date: Thu, 23 Jul 2015 11:59:18 +0200 Subject: [PATCH] Add capability to camelize QuerySets --- djangorestframework_camel_case/util.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/djangorestframework_camel_case/util.py b/djangorestframework_camel_case/util.py index 8a644b8..1dc5c07 100644 --- a/djangorestframework_camel_case/util.py +++ b/djangorestframework_camel_case/util.py @@ -1,6 +1,8 @@ from collections import OrderedDict import re +from django.db.models import QuerySet + first_cap_re = re.compile('(.)([A-Z][a-z]+)') all_cap_re = re.compile('([a-z0-9])([A-Z])') @@ -20,6 +22,11 @@ def camelize(data): for i in range(len(data)): data[i] = camelize(data[i]) return data + if isinstance(data, QuerySet): + new_list = [] + for i in range(len(data)): + new_list.append(camelize(data[i])) + return new_list return data @@ -39,4 +46,4 @@ def underscoreize(data): for i in range(len(data)): data[i] = underscoreize(data[i]) return data - return data \ No newline at end of file + return data