diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 98143a6..794c39f 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -161,6 +161,7 @@ stored in :class:`~eav.models.Value`). Available choices are: *object* ``TYPE_OBJECT`` *enum* ``TYPE_ENUM`` *json* ``TYPE_JSON`` +*csv* ``TYPE_CSV`` ========= ================== If you want to create an attribute with data-type *enum*, you need to provide @@ -213,6 +214,32 @@ The attribute type *json* allows to store them in JSON format, which internally Product.objects.filter(eav__name_intl__has_key="it") , ]> +The attribute type *csv* allows to store Comma Separated Values, using ";" as a separator: + +.. code-block:: python + + Attribute.objects.create(name='colors', datatype=Attribute.TYPE_CSV) + + prod = Product.objects.create(sku='PRD00001', eav__colors="red;green;blue") + + prod2 = Product.objects.create(sku='PRD00002', eav__colors="red;green") + + prod3 = Product.objects.create(sku='PRD00003', eav__colors="red;blue") + + prod4 = Product.objects.create(sku='PRD00004', eav__colors="") + + prod.eav.colors + ["red", "green", "blue"] + + type(prod.eav.name_intl) + list + + Product.objects.filter(eav__name_colors="green") + , ]> + + Product.objects.filter(~Q(eav__name_colors__isnull=False)) + ]> + Finally, attribute type *object* allows to relate Django model instances via generic foreign keys: