From 3d2c48ae36a1a9a0a6b26f427bd68bc42a26c7c4 Mon Sep 17 00:00:00 2001 From: Mauro Date: Mon, 10 May 2021 17:17:49 -0300 Subject: [PATCH] Updating docs --- docs/source/usage.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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: