mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-03-16 22:40:26 +00:00
2.1 KiB
2.1 KiB
Django EAV 2 - Entity-Attribute-Value storage for Django
Django EAV 2 is a fork of django-eav (which itself was derived from eav-django). You can find documentation here.
Installation
You can install django-eav2 from three sources:
# From PyPI via pip
pip install django-eav2
# From source via pip
pip install git+https://github.com/makimo/django-eav2@master
# From source via setuptools
git clone git@github.com:makimo/django-eav2.git
cd django-eav2
python setup.py install
# To uninstall:
python setup.py install --record files.txt
rm $(cat files.txt)
Getting started
Step 1. Register a model:
import eav
eav.register(Supplier)
or with decorators:
from eav.decorators import register_eav
@register_eav
class Supplier(models.Model):
...
Step 2. Create an attribute:
Attribute.objects.create(name='City', datatype=Attribute.TYPE_TEXT)
Step 3. That’s it! You’re ready to go:
supplier.eav.city = 'London'
supplier.save()
Supplier.objects.filter(eav__city='London')
# = <EavQuerySet [<Supplier: Supplier object (1)>]>