Skip to content

Commit

Permalink
Remove now unused ListDictField from base serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
erinspace committed Jul 24, 2018
1 parent be0069e commit 694466c
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions api/base/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import furl
from django.core.urlresolvers import resolve, reverse, NoReverseMatch
from django.core.exceptions import ImproperlyConfigured
from django.utils import six

from rest_framework import exceptions, permissions
from rest_framework import serializers as ser
Expand Down Expand Up @@ -963,27 +962,6 @@ def to_representation(self, obj):
return ret


class ListDictField(ser.DictField):

def __init__(self, **kwargs):
super(ListDictField, self).__init__(**kwargs)

def to_representation(self, value):
"""
Ensure the value of each key in the Dict to be a list
"""
res = {}
for key, val in value.items():
if isinstance(self.child.to_representation(val), list):
res[six.text_type(key)] = self.child.to_representation(val)
else:
if self.child.to_representation(val):
res[six.text_type(key)] = [self.child.to_representation(val)]
else:
res[six.text_type(key)] = []
return res


_tpl_pattern = re.compile(r'\s*<\s*(\S*)\s*>\s*')


Expand Down

0 comments on commit 694466c

Please sign in to comment.