mvpdev/django-eav — Issue #9: Can not use EAV model in ManyToMany relation
Author: haizaar
Created: 2011-11-15 15:59:38+00:00
State: open

Consider the following example:

```python
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:
```python
Caught AttributeError while rendering: Fruit does not have attribute named "attrs".
```

The problem is that django ModelMultipleChoiceField does this:
```python
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 __item__ method, prepare_value tries to iterate it and it goes wrong.