mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-04-28 10:54:42 +00:00
Update README
This commit is contained in:
parent
f13cce9dcd
commit
6a3e88bfc6
1 changed files with 37 additions and 32 deletions
|
|
@ -1,24 +1,32 @@
|
|||
django-eav
|
||||
==========
|
||||
### django-eav2 - Entity-Attribute-Value storage model for Django
|
||||
|
||||
#### Introduction
|
||||
|
||||
Introduction
|
||||
------------
|
||||
django-eav2 is a fork of django-eav (which itself was derived from eav-django).
|
||||
This project aims to:
|
||||
|
||||
django-eav provides an Entity-Attribute-Value storage model for django apps.
|
||||
- [ ] add Python 3 support
|
||||
- [ ] add Django 1.11 and 2.0 support
|
||||
- [ ] drop Django <1.11 dependencies
|
||||
- [ ] remove dependency on Sites framework
|
||||
- [ ] fix unresolved issues
|
||||
- [ ] update documentation
|
||||
- [ ] update/create tests
|
||||
|
||||
#### Overview
|
||||
|
||||
For a decent explanation of what an Entity-Attribute-Value storage model is,
|
||||
check `Wikipedia
|
||||
<http://en.wikipedia.org/wiki/Entity-attribute-value_model>`_.
|
||||
|
||||
.. note::
|
||||
This software was inspired / derived from the excellent `eav-django
|
||||
django-eav was inspired / derived from the excellent `eav-django
|
||||
<http://pypi.python.org/pypi/eav-django/1.0.2>`_ written by Andrey
|
||||
Mikhaylenko.
|
||||
|
||||
|
||||
There are a few notable differences between this implementation and the
|
||||
eav-django implementation.
|
||||
|
||||
|
||||
* This one is called django-eav, whereas the other is called eav-django.
|
||||
* This app allows you to to 'attach' EAV attributes to any existing django
|
||||
model (even from third-party apps) without making any changes to the those
|
||||
|
|
@ -26,20 +34,20 @@ check `Wikipedia
|
|||
* This app has slightly more robust (but still not perfect) filtering.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
#### Installation
|
||||
|
||||
From Github
|
||||
~~~~~~~~~~~
|
||||
You can install django-eav directly from guthub::
|
||||
##### GitHub
|
||||
|
||||
pip install -e git+git://github.com/mvpdev/django-eav.git#egg=django-eav
|
||||
You can install django-eav2 directly from github::
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
```
|
||||
pip install -e git+git://github.com/makimo/djang-eav2.git#egg=django-eav
|
||||
```
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
##### Django Sites Framework
|
||||
|
||||
Django Sites Framework
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
As of Django 1.7, the `Sites framework <https://docs.djangoproject.com/en/1.8/ref/contrib/sites/#enabling-the-sites-framework>`_ is not enabled by default; Django-EAV requires this framework.
|
||||
To enable the sites framework, follow these steps:
|
||||
|
||||
|
|
@ -51,16 +59,14 @@ Define a ``SITE_ID`` setting::
|
|||
|
||||
Run ``migrate``
|
||||
|
||||
#### Usage
|
||||
|
||||
Usage
|
||||
-----
|
||||
##### Edit settings.py
|
||||
|
||||
Edit settings.py
|
||||
~~~~~~~~~~~~~~~~
|
||||
Add ``eav`` to your ``INSTALLED_APPS`` in your project's ``settings.py`` file. Be sure to add eav to the installed apps list AFTER the sites framework!
|
||||
|
||||
Register your model(s)
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
##### Register your model(s)
|
||||
|
||||
Before you can attach eav attributes to your model, you must register your
|
||||
model with eav::
|
||||
|
||||
|
|
@ -75,8 +81,8 @@ declarations. Alternatively, you can use the registration decorator provided::
|
|||
class MyModel(models.Model):
|
||||
...
|
||||
|
||||
Create some attributes
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
##### Create some attributes
|
||||
|
||||
::
|
||||
|
||||
>>> from eav.models import Attribute
|
||||
|
|
@ -84,8 +90,8 @@ Create some attributes
|
|||
>>> Attribute.objects.create(name='Color', datatype=Attribute.TYPE_TEXT)
|
||||
|
||||
|
||||
Assign eav values
|
||||
~~~~~~~~~~~~~~~~~
|
||||
##### Assign eav values
|
||||
|
||||
::
|
||||
|
||||
>>> m = MyModel()
|
||||
|
|
@ -100,8 +106,8 @@ Assign eav values
|
|||
|
||||
>>> p = MyModel.objects.create(eav__weight = 12, eav__color='red')
|
||||
|
||||
Filter on eav values
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
##### Filter on eav values
|
||||
|
||||
::
|
||||
|
||||
>>> MyModel.objects.filter(eav__weight=15.4)
|
||||
|
|
@ -109,7 +115,6 @@ Filter on eav values
|
|||
>>> MyModel.objects.exclude(name='bob', eav__weight=15.4, eav__color='red')
|
||||
|
||||
|
||||
Documentation and Examples
|
||||
--------------------------
|
||||
#### Documentation and Examples
|
||||
|
||||
`<http://mvpdev.github.com/django-eav>`_
|
||||
Loading…
Reference in a new issue