Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql queries fail: "unhashable type: 'MSFList'" #138

Open
sanderboer opened this issue Jan 18, 2023 · 2 comments
Open

graphql queries fail: "unhashable type: 'MSFList'" #138

sanderboer opened this issue Jan 18, 2023 · 2 comments

Comments

@sanderboer
Copy link

I have made a model that uses a MultiSelectField. When I create a schema.py to query all entries of that model, it fails with the error: "unhashable type: 'MSFList'"

Is there a way to remedy this ?

thank you.

@sanderboer
Copy link
Author

sanderboer commented Jan 19, 2023

NB: Right now I copy the multiselectfield into a _str duplicate using the "save" method and I ignore the ages_allowed field in Graphql and read ages_allowed_str instead.

`
class Question(models.Model):
title = models.CharField(max_length=256)
ages_allowed = MultiSelectField(
choices=AGES,
null=False,
default=0,
max_length=get_max_length(AGES, None),
)
ages_allowed_str = models.CharField(max_length=256, blank=True)
info = models.TextField()
image = models.ImageField(upload_to=photo_path, blank=True)
published_at = models.DateTimeField(default=timezone.now)
author = models.ForeignKey(User, on_delete=models.CASCADE)
type = models.CharField(
max_length=64,
choices=ANSWERTYPE,
default="boolean",
)

    def save(self, *args, **kwargs):
            self.ages_allowed_str = ",".join(self.ages_allowed)
            super().save(*args, **kwargs)
        
    def __str__(self):
            return self.title
    
    def __unicode__(self):
            return self.__str__()

`

@karolyi
Copy link
Contributor

karolyi commented May 24, 2024

Can you please recheck with #135 ?

Not sure but this might fix your issue. If not, it'll be probably way easier to fix than before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants