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

Can not use EAV model in ManyToMany relation #9

Open
haizaar opened this issue Nov 15, 2011 · 0 comments
Open

Can not use EAV model in ManyToMany relation #9

haizaar opened this issue Nov 15, 2011 · 0 comments

Comments

@haizaar
Copy link

haizaar commented Nov 15, 2011

Consider the following example:

class Fruit(BaseEntity):
    title = models.CharField(max_length=50)

class Customer(models.Model):
   name = models.CharField(max_length=50)
   fruits = odels.ManyToManyField(Fruit)

Trying to edit Customer in django admin will complain:

Caught AttributeError while rendering: Fruit does not have attribute named "attrs".

The problem is that django ModelMultipleChoiceField does this:

    def prepare_value(self, value):
        if hasattr(value, '__iter__'):
            return [super(ModelMultipleChoiceField, self).prepare_value(v) for v in value]
        return super(ModelMultipleChoiceField, self).prepare_value(value)

I.e. since Fruit has __iter__ method, prepare_value tries to iterate it and it goes wrong.

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

1 participant