ambv/dj.choices

django "__in" is not working with dj.choices objects

mrezk opened this issue · 4 comments

I have the following classes:

class Status(Choices):
    good = Choice("good")
    bad = Choice("bad")
    ugly = Choice("ugly")

class StatusHolder(models.Model):
    status = ChoiceField(choices=Status, default=Status.good)
    ...

If I do:

StatusHolder.objects.filter(status__in=[Status.good, Status.ugly])

I get:

AttributeError: 'list' object has no attribute 'id'

I think this should work as any other field, am I right?

ambv commented

You're right. I will investigate this. Django 1.4?

Forgot to say, I'm using Django 1.3!

Thanks man! It worked great!

ambv commented

Thanks for reporting the bug.