Commits

Andy Mikhailenko committed 69873ce Merge

Merged pull request #8 by buremba

BaseEntity needs generic attrs field to be able to function.

Comments (0)

Files changed (1)

examples/grocery_shop/grocery/models.py

 # eav
 from eav.models import BaseChoice, BaseEntity, BaseSchema, BaseAttribute
 
-
+class Attribute(BaseAttribute):
+    schema = models.ForeignKey(Schema, related_name='attrs')
+    choice = models.ForeignKey(Choice, blank=True, null=True)
+    
 class Fruit(BaseEntity):
     title = models.CharField(max_length=50)
-
+    attrs = generic.GenericRelation(Attribute, object_id_field='entity_id',
+                                    content_type_field='entity_type')
     @classmethod
     def get_schemata_for_model(self):
         return Schema.objects.all()
 class Choice(BaseChoice):
     schema = models.ForeignKey(Schema, related_name='choices')
 
-
-class Attribute(BaseAttribute):
-    schema = models.ForeignKey(Schema, related_name='attrs')
-    choice = models.ForeignKey(Choice, blank=True, null=True)
-
-