django-eav2/README.md
2018-06-29 14:33:06 +02:00

2.1 KiB
Raw Blame History

Build Status Coverage Status Codacy Badge Maintainability Python Version Django Version

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. Thats it! Youre ready to go:

supplier.eav.city = 'London'
supplier.save()

Supplier.objects.filter(eav__city='London')
# = <EavQuerySet [<Supplier: Supplier object (1)>]>

What next? Check out documentation.