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

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

        # Handle updating the `categories` field of blog posts using flat representation (comma delimited)
        if categories is not None:
            if categories:
                # Disassociate any blog post categories not included in the request
                cat_titles = [name for name in categories.split(',')]
                for category in instance.categories.all():
                    if cat_titles not in category.title:
                        instance.categories.remove(category)

                # Add any new categories from the request that are not already associated with the blog post
                for name in categories.split(','):
                    name = name.strip()
                    cat, created = BlogCategory.objects.get_or_create(title=name)
                    instance.categories.add(cat)
            else:
                # Categories is an empty string, so disassociate all categories from the blog post
                for category in instance.categories.all():
                    instance.categories.remove(category)

        instance.save()

        return instance
dataset/ETHPy150Open gcushen/mezzanine-api/mezzanine_api/serializers.py/PostUpdateSerializer.update/swapped operands of `not in`