Commit 2c9d38e8 authored by Alokik Vijay's avatar Alokik Vijay
Browse files

[4.1.x] Fixed #30711 -- Doc'd django.contrib.postgres.fields.hstore.KeyTransform().

parent 0c6c32035a52
......@@ -319,6 +319,22 @@ transform do not change. For example::
valid for a given field. This can be done using the
:class:`~django.contrib.postgres.validators.KeysValidator`.
KeyTransform() expression
-------------------------
.. class:: hstore.KeyTransform(key_name, *args, **kwargs)
Returns the value of the given ``key_name``. This allows you to annotate a key
value. For example::
>>> from django.contrib.postgres.fields.hstore import KeyTransform
>>> Dog.objects.create(name="Rufus", data={"breed": "labrador"})
>>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})
>>> rufus = Dog.objects.annotate(breed=KeyTransform("breed", "data"))[0]
>>> rufus.breed
'labrador'
Querying ``HStoreField``
------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment