1. Andy Mikhailenko
  2. eav-django

Commits

buremba  committed 3124981

BaseEntity need generic attrs field to be able to function.

  • Participants
  • Parent commits 4b4493d
  • Branches default

Comments (0)

Files changed (1)

File examples/grocery_shop/grocery/models.py

View file
 # 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)
-
-