Metadata-Version: 2.4
Name: django-hstore-field
Version: 0.0.5
Summary: An easy to use postgres hstore field that is based on django-hstore-widget
Project-URL: Homepage, https://github.com/baseplate-admin/django-hstore-field
Project-URL: Repository, https://github.com/baseplate-admin/django-hstore-field
Project-URL: Bug Tracker, https://github.com/baseplate-admin/django-hstore-field/issues
Author-email: baseplate-admin <61817579+baseplate-admin@users.noreply.github.com>
Maintainer-email: baseplate-admin <61817579+baseplate-admin@users.noreply.github.com>
License: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.1
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: django-hstore-widget>=0.0.25
Description-Content-Type: text/markdown

# django-hstore-field



[![PyPI Downloads](https://static.pepy.tech/badge/django-hstore-field)](https://pepy.tech/projects/django-hstore-field) [![CI](https://github.com/baseplate-admin/django-hstore-field/actions/workflows/CI.yaml/badge.svg)](https://github.com/baseplate-admin/django-hstore-field/actions/workflows/CI.yaml) [![Pypi Badge](https://img.shields.io/pypi/v/django-hstore-field.svg)](https://pypi.org/project/django-hstore-field/) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/baseplate-admin/django-hstore-field/master.svg)](https://results.pre-commit.ci/latest/github/baseplate-admin/django-hstore-field/master)

An easy to use [postgres hstore](https://www.postgresql.org/docs/current/hstore.html) field that is based on [`django-hstore-widget`](https://github.com/baseplate-admin/django-hstore-widget)

## Requirements

-   Python 3.10 and Up ( well technically any python version from 3.6 should work )
-   Django 3.2 and Up
-   Modern browsers ( Chrome 112+, Firefox 117+, Safari 16.5+ or [any browsers supporting css nesting](https://caniuse.com/css-nesting) ) 

## Installation

```bash
pip install django-hstore-field
```

## Usage


### Option 1:

Include [`django-hstore-widget`](https://github.com/baseplate-admin/django-hstore-widget) in your `settings.py`'s `INSTALLED_APPS`:

```python

# settings.py

INSTALLED_APPS = [
    ...,
    'django_hstore_widget',
    ...
]

```


### Option 2:

Include  [`django-hstore-widget`](https://github.com/baseplate-admin/django-hstore-widget)'s migration to any of your model's migration:


```python
# Generated migration file
from django.db import migrations, models
import django.contrib.postgres.fields


class Migration(migrations.Migration):
    dependencies = [
        ("django_hstore_widget", "__latest__"),
    ]

    operations = [
        ...
    ]

```

and then use it:

```python
# yourapp/models.py
from django.db import models
from django_hstore_field import HStoreField


class ExampleModel(models.Model):
    data = HStoreField()
```

### Indexing

You should use GIN indexing for 99% of the use case, create an index like this:

```python
# models.py
from django.db import models
from django.contrib.postgres.indexes import GinIndex
from django_hstore_field import HStoreField


class ExampleModel(models.Model):
    data = HStoreField()

    class Meta:
        indexes = [
            GinIndex(fields=["data"], name="example_data_gin"),
        ]
```

### Example: 

Check the [`cat` directory](https://github.com/baseplate-admin/django-hstore-field/tree/master/tests/cat)

> [!NOTE]  
If you want a lower level implementation, please check [django-hstore-widget](https://github.com/baseplate-admin/django-hstore-widget).

