django-eav2/README.md

69 lines
2.1 KiB
Markdown
Raw Normal View History

2018-06-29 12:33:06 +00:00
2018-06-01 14:15:07 +00:00
[![Build Status](https://travis-ci.org/makimo/django-eav2.svg?branch=master)](https://travis-ci.org/makimo/django-eav2)
2018-06-01 15:19:49 +00:00
[![Coverage Status](https://coveralls.io/repos/github/makimo/django-eav2/badge.svg?branch=master)](https://coveralls.io/github/makimo/django-eav2?branch=master)
2018-06-04 11:09:38 +00:00
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/159540d899bd41bb860f0ce996427e1f)](https://www.codacy.com/app/IwoHerka/django-eav2?utm_source=github.com&utm_medium=referral&utm_content=makimo/django-eav2&utm_campaign=Badge_Grade)
2018-06-03 13:14:15 +00:00
[![Maintainability](https://api.codeclimate.com/v1/badges/b90eacf7a90db4b58f13/maintainability)](https://codeclimate.com/github/makimo/django-eav2/maintainability)
2018-06-08 16:15:26 +00:00
![Python Version](https://img.shields.io/badge/Python-2.7,%203.5,%203.6,%203.7dev-blue.svg)
![Django Version](https://img.shields.io/badge/Django-1.11,%202.0,%20tip-green.svg)
2018-06-01 14:15:07 +00:00
2018-06-29 12:33:06 +00:00
## Django EAV 2 - Entity-Attribute-Value storage for Django
2010-09-28 13:39:57 +00:00
Django EAV 2 is a fork of django-eav (which itself was derived from eav-django).
You can find documentation <a href="https://django-eav-2.rtfd.io">here</a>.
2010-09-28 13:39:57 +00:00
2018-06-29 12:33:06 +00:00
## Installation
You can install **django-eav2** from three sources:
```bash
# From PyPI via pip
pip install django-eav2
2018-06-01 12:29:17 +00:00
2018-06-29 12:33:06 +00:00
# From source via pip
pip install git+https://github.com/makimo/django-eav2@master
2018-06-06 23:02:04 +00:00
2018-06-29 12:33:06 +00:00
# From source via setuptools
git clone git@github.com:makimo/django-eav2.git
cd django-eav2
python setup.py install
2018-06-06 23:02:04 +00:00
2018-06-29 12:33:06 +00:00
# To uninstall:
python setup.py install --record files.txt
rm $(cat files.txt)
2018-06-06 23:02:04 +00:00
```
2018-06-29 12:33:06 +00:00
## Getting started
2018-06-06 23:02:04 +00:00
2018-06-29 12:33:06 +00:00
**Step 1.** Register a model:
```python
import eav
eav.register(Supplier)
2018-06-06 23:02:04 +00:00
```
2018-06-29 12:33:06 +00:00
or with decorators:
```python
from eav.decorators import register_eav
@register_eav
class Supplier(models.Model):
...
2018-06-06 23:02:04 +00:00
```
2018-06-29 12:33:06 +00:00
**Step 2.** Create an attribute:
```python
Attribute.objects.create(name='City', datatype=Attribute.TYPE_TEXT)
2018-06-06 23:02:04 +00:00
```
2018-06-29 12:33:06 +00:00
**Step 3.** Thats it! Youre ready to go:
```python
supplier.eav.city = 'London'
supplier.save()
Supplier.objects.filter(eav__city='London')
# = <EavQuerySet [<Supplier: Supplier object (1)>]>
2018-06-06 23:02:04 +00:00
```
2018-06-29 12:33:06 +00:00
2018-07-11 11:18:07 +00:00
### What next? Check out <a href="https://django-eav-2.readthedocs.io/en/improvement-docs/">documentation</a>.