def create(self, validated_data):
        # Pop categories attribute to process later
        try:
            categories = validated_data.pop("categories")
        except __HOLE__:
            categories = None

        # Create a new blog post with core attributes
        initial = {
            "title": validated_data.pop("title"),
            "user": self.context['request'].user,
        }
        post = Post.objects.create(**initial)

        # Update all other object attributes that were supplied in the request (except categories)
        for k, v in validated_data.items():
            setattr(post, k, v)

        # Create categories as necessary from a comma delimited representation and associate them with the blog post
        if categories:
            for name in categories.split(','):
                name = name.strip()
                cat, created = BlogCategory.objects.get_or_create(title=name)
                post.categories.add(cat)

        post.save()

        # Note: response body returned by API on CREATE shows "categories": "blog.BlogCategory.None" rather than
        # the successfully processed comma delimited category list specified in the request.

        return post
dataset/ETHPy150Open gcushen/mezzanine-api/mezzanine_api/serializers.py/PostCreateSerializer.create