예제 #1
0
파일: serializers.py 프로젝트: plan1230/nav
    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
예제 #2
0
    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