Skip settings field validation for encrypted fields if submitted value is the $encrypted$ placeholder.

This commit is contained in:
Chris Church 2016-12-06 19:36:28 -05:00
parent 9feef6e76a
commit f2e2ca30ab

View File

@ -50,6 +50,8 @@ class SettingFieldMixin(object):
return obj
def to_internal_value(self, value):
if getattr(self, 'encrypted', False) and isinstance(value, basestring) and value.startswith('$encrypted$'):
raise serializers.SkipField()
obj = super(SettingFieldMixin, self).to_internal_value(value)
return super(SettingFieldMixin, self).to_representation(obj)