def create(self, validated_data): categories = set(validated_data.pop('categories')) instance = profiles.NetmapView(**validated_data) instance.save() self._update_categories(instance, categories) return instance
def restore_object(self, attrs, instance=None): if instance is not None: for key, value in iteritems(attrs): setattr(instance, key, value) return instance categories = attrs.pop('categories') instance = profiles.NetmapView(**attrs) setattr(instance, 'categories', categories) return instance