diff --git a/README.md b/README.md index ef51c8b..3c8600d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + [![Build Status](https://travis-ci.org/makimo/django-eav2.svg?branch=master)](https://travis-ci.org/makimo/django-eav2) [![Coverage Status](https://coveralls.io/repos/github/makimo/django-eav2/badge.svg?branch=master)](https://coveralls.io/github/makimo/django-eav2?branch=master) [![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) @@ -5,41 +6,63 @@ ![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) -### Django EAV 2 - Entity-Attribute-Value storage for Django +## Django EAV 2 - Entity-Attribute-Value storage for Django -#### Introduction +Django EAV 2 is a fork of django-eav (which itself was derived from eav-django). +You can find documentation here. -Django EAV 2 is a fork of django-eav (which itself was derived from eav-django). -This project aims to: +## Installation +You can install **django-eav2** from three sources: +```bash +# From PyPI via pip +pip install django-eav2 -- add Python 3 support -- add Django 1.11 and 2.0 support -- modernize and clean-up the codebase -- drop Django <1.11 dependencies -- remove dependency on Sites framework -- fix unresolved issues -- update documentation (Sphinx + ReadTheDocs) -- create exhaustive (and automated) tests -- add new features - -(For now) our progress can be tracked through issues. Feel free -to join the discussion. - -### Installing from git - -``` +# From source via pip pip install git+https://github.com/makimo/django-eav2@master -``` -### Installing from source - -``` +# From source via setuptools git clone git@github.com:makimo/django-eav2.git cd django-eav2 python setup.py install -``` -To uninstall: -``` + +# To uninstall: python setup.py install --record files.txt rm $(cat files.txt) ``` + +## Getting started + +**Step 1.** Register a model: + +```python +import eav +eav.register(Supplier) +``` + +or with decorators: + +```python +from eav.decorators import register_eav + +@register_eav +class Supplier(models.Model): + ... +``` + +**Step 2.** Create an attribute: + +```python +Attribute.objects.create(name='City', datatype=Attribute.TYPE_TEXT) +``` + +**Step 3.** That’s it! You’re ready to go: + +```python +supplier.eav.city = 'London' +supplier.save() + +Supplier.objects.filter(eav__city='London') +# = ]> +``` + +### What next? Check out documentation.