1

I'm using the package django-taggit with graphene-django. Initially, I was getting the error specified in this question (Don't know how to convert the Django field skills (<class 'taggit.managers.TaggableManager'>); but thanks to the answers there, I resolved the issue. However, there's another issue!

I have the following mixin:

class GrapheneRenderTaggitTags:
    """
    Use this mixin to enable graphene-django correctly render django-taggit 
    tags (as a list of strings).
    The corresponding model of the graphene type using this mixin should have a property
    `get_tags` that returns the tags of the model (e.g. obj.tags.all())
    """

    # Make django-taggit's TaggableManager interpretable to graphene
    @convert_django_field.register(TaggableManager)
    def convert_field_to_string(field, registry=None):
        print(field)
        print("i'm in the taggit parser function")
        return List(String, source='get_tags')

When I use this mixin with the DjangoObjectType from graphene, it works flawlessly. However, when it comes to mutations, it raises the error Don't know how to convert the Django field skills (<class 'taggit.managers.TaggableManager'>) !
By the way, to prevent manually creating CUD mutations, I tried external packages such as graphene_django_extras, graphene_model_mutations, graphene_django_cud; but all of them raise the same error with or without the aforementioned mixin.
Note that I get this error only when using the mutation classes provided by these packages.

Please, what can I do to get this to work without manually writing all the logic for CUD operations, i.e. by using a package (any package) that automatically generates mutations from my models ?

Or do I have no other choice than to manually create my mutations?

ImportError
  • 358
  • 5
  • 17

0 Answers0