# Dokumentasi Django 5.2.8

# Bidang-bidang model khusus PostgreSQL

Semua dari bidang ini tersedia dari modul `django.contrib.postgres.fields`.

## Mengindeks bidang-bidang ini

`Index` and `Field.db_index` both create a B-tree index, which isn't particularly helpful when querying complex data types. Indexes such as `GinIndex` and `GistIndex` are better suited, though the index choice is dependent on the queries that you're using. Generally, GiST may be a good choice for the range fields and `HStoreField`, and GIN may be helpful for `ArrayField`.

## `ArrayField`

class ArrayField(base_field, size=None, **options)

  A field for storing lists of data. Most field types can be used, and you pass another field instance as the `base_field`. You may also specify a `size`. `ArrayField` can be nested to store multi-dimensional arrays.

  Jika anda memberikan bidang `default`, pastikan itu adalah callable seperti `list` (untuk sebuah nilai kosong) atau sebuah callable yang mengembalikan list (seperti sebuah fungsi). Salah menggunakan `default=[]` membuat awalan yang berubah-ubah yaitu dibagi diantara semua contoh dari `ArrayField`.

  base_field

    Ini adalah sebuah argumen diwajibkan.

    Specifies the underlying data type and behavior for the array. It should be an instance of a subclass of `Field`. For example, it could be an `IntegerField` or a `CharField`. Most field types are permitted, with the exception of those handling relational data (`ForeignKey`, `OneToOneField` and `ManyToManyField`) and file fields (`FileField` and `ImageField`).

    Itu memungkinkan menyarang bidang-bidang larik - anda dapat menentukan sebuah instance dari `ArrayField` sebagai `base_field`. Sebagai contoh:

        from django.contrib.postgres.fields import ArrayField
        from django.db import models

        class ChessBoard(models.Model):
            board = ArrayField(
                ArrayField(
                    models.CharField(max_length=10, blank=True),
                    size=8,
                ),
                size=8,
            )

    Perubahan dari nilai-nilai diantara basisdata dan model, pengesahan dari data dan konfigurasi, dan serialisasi adalah semua dilimpahkan ke bidang dasar pokok.

  size

    Ini adalah sebuah argumen pilihan.

    Jika dilewatkan, larik akan memiliki ukuran maksimal seperti ditentukan. Ini akan dilewatkan ke basisdata meskipun PostgreSQL saat sekarang tidak melaksanakan batasan.

Catatan

When nesting `ArrayField`, whether you use the `size` parameter or not, PostgreSQL requires that the arrays are rectangular:

    from django.contrib.postgres.fields import ArrayField
    from django.db import models

    class Board(models.Model):
        pieces = ArrayField(ArrayField(models.IntegerField()))

    # Valid
    Board(
        pieces=[
            [2, 3],
            [2, 1],
        ]
    )

    # Not valid
    Board(
        pieces=[
            [2, 3],
            [2],
        ]
    )

Jika bentuk-bentuk tidak beraturan, kemudian bidang pokok harus dibuat null dan nilai-nilai ditambah dengan `None`.

### Meminta `ArrayField`

Ada sejumlah pencarian penyesuaian dan merubah untuk `ArrayField`. Kami akan menggunakan model contoh berikut:

    from django.contrib.postgres.fields import ArrayField
    from django.db import models

    class Post(models.Model):
        name = models.CharField(max_length=200)
        tags = ArrayField(models.CharField(max_length=200), blank=True)

        def __str__(self):
            return self.name

#### `contains`

The `contains` lookup is overridden on `ArrayField`. The returned objects will be those where the values passed are a subset of the data. It uses the SQL operator `@>`. For example:

    >>> Post.objects.create(name="First post", tags=["thoughts", "django"])
    >>> Post.objects.create(name="Second post", tags=["thoughts"])
    >>> Post.objects.create(name="Third post", tags=["tutorial", "django"])

    >>> Post.objects.filter(tags__contains=["thoughts"])
    <QuerySet [<Post: First post>, <Post: Second post>]>

    >>> Post.objects.filter(tags__contains=["django"])
    <QuerySet [<Post: First post>, <Post: Third post>]>

    >>> Post.objects.filter(tags__contains=["django", "thoughts"])
    <QuerySet [<Post: First post>]>

#### `contained_by`

This is the inverse of the `contains` lookup - the objects returned will be those where the data is a subset of the values passed. It uses the SQL operator `<@`. For example:

    >>> Post.objects.create(name="First post", tags=["thoughts", "django"])
    >>> Post.objects.create(name="Second post", tags=["thoughts"])
    >>> Post.objects.create(name="Third post", tags=["tutorial", "django"])

    >>> Post.objects.filter(tags__contained_by=["thoughts", "django"])
    <QuerySet [<Post: First post>, <Post: Second post>]>

    >>> Post.objects.filter(tags__contained_by=["thoughts", "django", "tutorial"])
    <QuerySet [<Post: First post>, <Post: Second post>, <Post: Third post>]>

#### `overlap`

Returns objects where the data shares any results with the values passed. Uses the SQL operator `&&`. For example:

    >>> Post.objects.create(name="First post", tags=["thoughts", "django"])
    >>> Post.objects.create(name="Second post", tags=["thoughts", "tutorial"])
    >>> Post.objects.create(name="Third post", tags=["tutorial", "django"])

    >>> Post.objects.filter(tags__overlap=["thoughts"])
    <QuerySet [<Post: First post>, <Post: Second post>]>

    >>> Post.objects.filter(tags__overlap=["thoughts", "tutorial"])
    <QuerySet [<Post: First post>, <Post: Second post>, <Post: Third post>]>

    >>> Post.objects.filter(tags__overlap=Post.objects.values_list("tags"))
    <QuerySet [<Post: First post>, <Post: Second post>, <Post: Third post>]>

#### `len`

Returns the length of the array. The lookups available afterward are those available for `IntegerField`. For example:

    >>> Post.objects.create(name="First post", tags=["thoughts", "django"])
    >>> Post.objects.create(name="Second post", tags=["thoughts"])

    >>> Post.objects.filter(tags__len=1)
    <QuerySet [<Post: Second post>]>

#### Perubahan indeks

Index transforms index into the array. Any non-negative integer can be used. There are no errors if it exceeds the `size` of the array. The lookups available after the transform are those from the `base_field`. For example:

    >>> Post.objects.create(name="First post", tags=["thoughts", "django"])
    >>> Post.objects.create(name="Second post", tags=["thoughts"])

    >>> Post.objects.filter(tags__0="thoughts")
    <QuerySet [<Post: First post>, <Post: Second post>]>

    >>> Post.objects.filter(tags__1__iexact="Django")
    <QuerySet [<Post: First post>]>

    >>> Post.objects.filter(tags__276="javascript")
    <QuerySet []>

Catatan

PostgreSQL menggunakan pengindeksan berdasarkan-1 untuk bidang larik ketika menulis SQL mentah. bagaimanapun indeks-indeks ini dan mereka digunakan dalam `slices` menggunakan pengindeksan berdasarkan-0 untuk tetap dengan Python.

#### Perubahan potongan

Slice transforms take a slice of the array. Any two non-negative integers can be used, separated by a single underscore. The lookups available after the transform do not change. For example:

    >>> Post.objects.create(name="First post", tags=["thoughts", "django"])
    >>> Post.objects.create(name="Second post", tags=["thoughts"])
    >>> Post.objects.create(name="Third post", tags=["django", "python", "thoughts"])

    >>> Post.objects.filter(tags__0_1=["thoughts"])
    <QuerySet [<Post: First post>, <Post: Second post>]>

    >>> Post.objects.filter(tags__0_2__contains=["thoughts"])
    <QuerySet [<Post: First post>, <Post: Second post>]>

Catatan

PostgreSQL menggunakan pengindeksan berdasarkan-1 untuk bidang larik ketika menulis SQL mentah. bagaimanapun potongan-potongan ini dan itu yang digunakan dalam `indexes` menggunakan pengindeksan berdasarkan-0 untuk tetap dengan Python.

Larik dimensi banyak dengan indeks dan potongan

PostgreSQL mempunyai beberapa perilaku esotorik ketika menggunakan pengindeksan dan pemotongan pada larik banyak dimensi. itu akan selalu bekerja mencapat ke data pokok akhir, tetapi kebanyakan potongan berperilaku aneh pada tingkat basisdata dan tidak dapat didukung dalam logika, gaya tetap oleh Django.

## `HStoreField`

class HStoreField(**options)

  Sebuah bidang untuk menyimpan pasangan nilai-kunci. Jenis data Python adalah sebuah `dict`. Kunci-kunci harus berupa string, dan nilai-nilai mungkin salah satu string atau null (`None` dalam Python).

  Untuk menggunakan bidang ini, anda akan butuh untuk:

  1. Tambah `'django.contrib.postgres'` dalam `INSTALLED_APPS` anda.

  2. Set up the hstore extension in PostgreSQL.

  Anda akan melihat sebuah kesalahan seperti `can't adapt type 'dict'` jika anda melewati langkah pertama, atau `type "hstore" does not exist` jika anda melewati kedua.

Catatan

Pada kesempatan itu mungkin berguna untuk membutuhkan atau membatasi kunci-kunci yang sah untuk bidang diberikan. Ini dapat dilakukan menggunakan `KeysValidator`.

### Meminta `HStoreField`

Sebagai tambahan pada kemampuan untuk pencarian berdasarkan kunci, ada angka dari pencarian penyesuaian tersedia untuk `HStoreField`.

Kami akan menggunakan model contoh berikut:

    from django.contrib.postgres.fields import HStoreField
    from django.db import models

    class Dog(models.Model):
        name = models.CharField(max_length=200)
        data = HStoreField()

        def __str__(self):
            return self.name

#### Kunci pencarian

To query based on a given key, you can use that key as the lookup name:

    >>> Dog.objects.create(name="Rufus", data={"breed": "labrador"})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie"})

    >>> Dog.objects.filter(data__breed="collie")
    <QuerySet [<Dog: Meg>]>

You can chain other lookups after key lookups:

    >>> Dog.objects.filter(data__breed__contains="l")
    <QuerySet [<Dog: Rufus>, <Dog: Meg>]>

or use `F()` expressions to annotate a key value. For example:

    >>> from django.db.models import F
    >>> rufus = Dog.objects.annotate(breed=F("data__breed"))[0]
    >>> rufus.breed
    'labrador'

Jika kunci yang anda ahrapkan untuk meminta berdasarkan ketidakcocokan dengan nama dari pencarian lain, anda butuh menggunakan pencarian `hstorefield.contains` lookup sebagai gantinya.

Catatan

Key transforms can also be chained with: `contains`, `icontains`, `endswith`, `iendswith`, `iexact`, `regex`, `iregex`, `startswith`, and `istartswith` lookups.

Peringatan

Sejak string apapun dapat berupa sebuah kunci dalam nilai hstore, pencarian apapun dari pada tersebut didaftar dibawah akan diartikan sebagai sebuah pencarian kunci. Tidak ada kesalahan akan dimunculkan. Ekstra hati-hati untuk menulis kesalahan, dan selalu memeriksa permintaan anda bekerja sesuai maksud anda.

#### `contains`

The `contains` lookup is overridden on `HStoreField`. The returned objects are those where the given `dict` of key-value pairs are all contained in the field. It uses the SQL operator `@>`. For example:

    >>> Dog.objects.create(name="Rufus", data={"breed": "labrador", "owner": "Bob"})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})
    >>> Dog.objects.create(name="Fred", data={})

    >>> Dog.objects.filter(data__contains={"owner": "Bob"})
    <QuerySet [<Dog: Rufus>, <Dog: Meg>]>

    >>> Dog.objects.filter(data__contains={"breed": "collie"})
    <QuerySet [<Dog: Meg>]>

#### `contained_by`

This is the inverse of the `contains` lookup - the objects returned will be those where the key-value pairs on the object are a subset of those in the value passed. It uses the SQL operator `<@`. For example:

    >>> Dog.objects.create(name="Rufus", data={"breed": "labrador", "owner": "Bob"})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})
    >>> Dog.objects.create(name="Fred", data={})

    >>> Dog.objects.filter(data__contained_by={"breed": "collie", "owner": "Bob"})
    <QuerySet [<Dog: Meg>, <Dog: Fred>]>

    >>> Dog.objects.filter(data__contained_by={"breed": "collie"})
    <QuerySet [<Dog: Fred>]>

#### `has_key`

Returns objects where the given key is in the data. Uses the SQL operator `?`. For example:

    >>> Dog.objects.create(name="Rufus", data={"breed": "labrador"})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})

    >>> Dog.objects.filter(data__has_key="owner")
    <QuerySet [<Dog: Meg>]>

#### `has_any_keys`

Returns objects where any of the given keys are in the data. Uses the SQL operator `?|`. For example:

    >>> Dog.objects.create(name="Rufus", data={"breed": "labrador"})
    >>> Dog.objects.create(name="Meg", data={"owner": "Bob"})
    >>> Dog.objects.create(name="Fred", data={})

    >>> Dog.objects.filter(data__has_any_keys=["owner", "breed"])
    <QuerySet [<Dog: Rufus>, <Dog: Meg>]>

#### `has_keys`

Returns objects where all of the given keys are in the data. Uses the SQL operator `?&`. For example:

    >>> Dog.objects.create(name="Rufus", data={})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})

    >>> Dog.objects.filter(data__has_keys=["breed", "owner"])
    <QuerySet [<Dog: Meg>]>

#### `keys`

Returns objects where the array of keys is the given value. Note that the order is not guaranteed to be reliable, so this transform is mainly useful for using in conjunction with lookups on `ArrayField`. Uses the SQL function `akeys()`. For example:

    >>> Dog.objects.create(name="Rufus", data={"toy": "bone"})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})

    >>> Dog.objects.filter(data__keys__overlap=["breed", "toy"])
    <QuerySet [<Dog: Rufus>, <Dog: Meg>]>

#### `values`

Returns objects where the array of values is the given value. Note that the order is not guaranteed to be reliable, so this transform is mainly useful for using in conjunction with lookups on `ArrayField`. Uses the SQL function `avals()`. For example:

    >>> Dog.objects.create(name="Rufus", data={"breed": "labrador"})
    >>> Dog.objects.create(name="Meg", data={"breed": "collie", "owner": "Bob"})

    >>> Dog.objects.filter(data__values__contains=["collie"])
    <QuerySet [<Dog: Meg>]>

## Bidang Jangkauan

Ada lima jenis jangkauan bidang, berhubungan ke jenis jangkauan siap-pakai dalam PostgreSQL. Bidang-bidang ini digunakan untuk menyimpan jangkauan dari nilai; sebagai contoh stempel waktu awal dan akhir dari sebuah acara, atau jangkauan dari umur sebuah aktivitas yang cocok.

All of the range fields translate to psycopg Range objects in Python, but also accept tuples as input if no bounds information is necessary. The default is lower bound included, upper bound excluded, that is `[)` (see the PostgreSQL documentation for details about different bounds). The default bounds can be changed for non-discrete range fields (`DateTimeRangeField` and `DecimalRangeField`) by using the `default_bounds` argument.

PostgreSQL normalizes a range with no points to the empty range

A range with equal values specified for an included lower bound and an excluded upper bound, such as `Range(datetime.date(2005, 6, 21), datetime.date(2005, 6, 21))` or `[4, 4)`, has no points. PostgreSQL will normalize the value to empty when saving to the database, and the original bound values will be lost. See the PostgreSQL documentation for details.

### `IntegerRangeField`

class IntegerRangeField(**options)

  Stores a range of integers. Based on an `IntegerField`. Represented by an `int4range` in the database and a `django.db.backends.postgresql.psycopg_any.NumericRange` in Python.

  Regardless of the bounds specified when saving the data, PostgreSQL always returns a range in a canonical form that includes the lower bound and excludes the upper bound, that is `[)`.

### `BigIntegerRangeField`

class BigIntegerRangeField(**options)

  Stores a range of large integers. Based on a `BigIntegerField`. Represented by an `int8range` in the database and a `django.db.backends.postgresql.psycopg_any.NumericRange` in Python.

  Regardless of the bounds specified when saving the data, PostgreSQL always returns a range in a canonical form that includes the lower bound and excludes the upper bound, that is `[)`.

### `DecimalRangeField`

class DecimalRangeField(default_bounds='[)', **options)

  Stores a range of floating point values. Based on a `DecimalField`. Represented by a `numrange` in the database and a `django.db.backends.postgresql.psycopg_any.NumericRange` in Python.

  default_bounds

    Optional. The value of `bounds` for list and tuple inputs. The default is lower bound included, upper bound excluded, that is `[)` (see the PostgreSQL documentation for details about different bounds). `default_bounds` is not used for `django.db.backends.postgresql.psycopg_any.NumericRange` inputs.

### `DateTimeRangeField`

class DateTimeRangeField(default_bounds='[)', **options)

  Stores a range of timestamps. Based on a `DateTimeField`. Represented by a `tstzrange` in the database and a `django.db.backends.postgresql.psycopg_any.DateTimeTZRange` in Python.

  default_bounds

    Optional. The value of `bounds` for list and tuple inputs. The default is lower bound included, upper bound excluded, that is `[)` (see the PostgreSQL documentation for details about different bounds). `default_bounds` is not used for `django.db.backends.postgresql.psycopg_any.DateTimeTZRange` inputs.

### `DateRangeField`

class DateRangeField(**options)

  Stores a range of dates. Based on a `DateField`. Represented by a `daterange` in the database and a `django.db.backends.postgresql.psycopg_any.DateRange` in Python.

  Regardless of the bounds specified when saving the data, PostgreSQL always returns a range in a canonical form that includes the lower bound and excludes the upper bound, that is `[)`.

### Meminta Jangkauan Bidang

Ada sejumlah pencarian penyesuaian dan perubahan untuk bidang jangkauan. Mereka tersedia pada semua bidang-bidang diatas, tetapi kami akan menggunakan model contoh berikut:

    from django.contrib.postgres.fields import IntegerRangeField
    from django.db import models

    class Event(models.Model):
        name = models.CharField(max_length=200)
        ages = IntegerRangeField()
        start = models.DateTimeField()

        def __str__(self):
            return self.name

We will also use the following example objects:

    >>> import datetime
    >>> from django.utils import timezone
    >>> now = timezone.now()
    >>> Event.objects.create(name="Soft play", ages=(0, 10), start=now)
    >>> Event.objects.create(
    ...     name="Pub trip", ages=(21, None), start=now - datetime.timedelta(days=1)
    ... )

dan `NumericRange`:

    >>> from django.db.backends.postgresql.psycopg_any import NumericRange

#### Fungsi-fungsi penahanan

Seperti bidang-bidang PostgreSQL lainnya, ada tiga standar penahanan penghubung: `contains`, `contained_by` dan `overlap`, menggunakan penghubung SQL `@>`, `<@`, dan `&&` masing-masing.

##### `contains`

    >>> Event.objects.filter(ages__contains=NumericRange(4, 5))
    <QuerySet [<Event: Soft play>]>

##### `contained_by`

    >>> Event.objects.filter(ages__contained_by=NumericRange(0, 15))
    <QuerySet [<Event: Soft play>]>

The `contained_by` lookup is also available on the non-range field types: `SmallAutoField`, `AutoField`, `BigAutoField`, `SmallIntegerField`, `IntegerField`, `BigIntegerField`, `DecimalField`, `FloatField`, `DateField`, and `DateTimeField`. For example:

    >>> from django.db.backends.postgresql.psycopg_any import DateTimeTZRange
    >>> Event.objects.filter(
    ...     start__contained_by=DateTimeTZRange(
    ...         timezone.now() - datetime.timedelta(hours=1),
    ...         timezone.now() + datetime.timedelta(hours=1),
    ...     ),
    ... )
    <QuerySet [<Event: Soft play>]>

##### `overlap`

    >>> Event.objects.filter(ages__overlap=NumericRange(8, 12))
    <QuerySet [<Event: Soft play>]>

#### Fungsi perbandingan

Bidang jangkauan mendukung pencarian standar: `lt`, `gt`, `lte` dan `gte`. Ini tidak terlalu membantu - mereka membandingkan batasan terendah dahulu dan batasan tertinggi hanya jika dibutuhkan. Ini juga strategi digunakan untuk mengurutkan berdasarkan bidang jangkauan. Itu lebih baik menggunakan penghubung perbandingan jangkauan khusus.

##### `fully_lt`

Jangkauan dikembalikan adalah sangat kurang dari jangkauan dilewatkan. Dengan kata lain, semua titik dalam jangkauan dikembalikan kurang dari semua dalam jangkauan dilewatkan.

    >>> Event.objects.filter(ages__fully_lt=NumericRange(11, 15))
    <QuerySet [<Event: Soft play>]>

##### `fully_gt`

Jangkauan dikembalikan adalah lebih besar dari jangkauan dilewatkan. Dengan kata lain, semua titik dalam jangkauan dikembalikan lebih besar dari semua dalam jangkauan dilewatkan.

    >>> Event.objects.filter(ages__fully_gt=NumericRange(11, 15))
    <QuerySet [<Event: Pub trip>]>

##### `not_lt`

Jangkauan dikembalikan tidak mengandung titik apapun kurang dari jangkauan dilewatkan, yaitu batasan terendah dari jangkauan dikembalikan adalah setidaknya batasan terendah dari jangkauan dilewatkan.

    >>> Event.objects.filter(ages__not_lt=NumericRange(0, 15))
    <QuerySet [<Event: Soft play>, <Event: Pub trip>]>

##### `not_gt`

Jangkauan dikembalikan tidak mengandung titik apapun lebih besar dari jangkauan dilewatkan, yaitu batasan tertinggi dari jangkauan dikembalikan adalah batasan paling tertinggi dari jangkauan dilewatkan.

    >>> Event.objects.filter(ages__not_gt=NumericRange(3, 10))
    <QuerySet [<Event: Soft play>]>

##### `adjacent_to`

Jangkauan dikembalikan berbagi sebuah batasan dengan jangkauan dilewatkan.

    >>> Event.objects.filter(ages__adjacent_to=NumericRange(10, 21))
    <QuerySet [<Event: Soft play>, <Event: Pub trip>]>

#### Meminta menggunakan batasan

Range fields support several extra lookups.

##### `startswith`

Obyek-obyek dikembalikan memiliki batasan terendah diberikan. Dapat diikat untuk pencarian sah untuk bidang dasar.

    >>> Event.objects.filter(ages__startswith=21)
    <QuerySet [<Event: Pub trip>]>

##### `endswith`

Obyek-obyek dikembalikan memiliki batasan tertinggi diberikan. Dapat diikat untuk pencarian sah untuk bidang dasar.

    >>> Event.objects.filter(ages__endswith=10)
    <QuerySet [<Event: Soft play>]>

##### `isempty`

Obyek-obyek dikembalikan adalah jangkauan kosong. Dapat diikat untuk pencarian sah untuk `BooleanField`.

    >>> Event.objects.filter(ages__isempty=True)
    <QuerySet []>

##### `lower_inc`

Returns objects that have inclusive or exclusive lower bounds, depending on the boolean value passed. Can be chained to valid lookups for a `BooleanField`.

    >>> Event.objects.filter(ages__lower_inc=True)
    <QuerySet [<Event: Soft play>, <Event: Pub trip>]>

##### `lower_inf`

Returns objects that have unbounded (infinite) or bounded lower bound, depending on the boolean value passed. Can be chained to valid lookups for a `BooleanField`.

    >>> Event.objects.filter(ages__lower_inf=True)
    <QuerySet []>

##### `upper_inc`

Returns objects that have inclusive or exclusive upper bounds, depending on the boolean value passed. Can be chained to valid lookups for a `BooleanField`.

    >>> Event.objects.filter(ages__upper_inc=True)
    <QuerySet []>

##### `upper_inf`

Returns objects that have unbounded (infinite) or bounded upper bound, depending on the boolean value passed. Can be chained to valid lookups for a `BooleanField`.

    >>> Event.objects.filter(ages__upper_inf=True)
    <QuerySet [<Event: Pub trip>]>

### Menentukan jenis jangkauan anda sendiri

PostgreSQL allows the definition of custom range types. Django's model and form field implementations use base classes below, and `psycopg` provides a `register_range()` to allow use of custom range types.

class RangeField(**options)

  Kelas dasar untuk bidang jangkauan model.

  base_field

    Kelas bidang model digunakan.

  range_type

    The range type to use.

  form_field

    Kelas bidang formulir digunakan. Harus berupa subkelas dari `django.contrib.postgres.forms.BaseRangeField`.

class django.contrib.postgres.forms.BaseRangeField

  Kelas dasar untuk formulir bidang jangkauan.

  base_field

    Bidang formulir digunakan.

  range_type

    The range type to use.

### Range operators

class RangeOperators

PostgreSQL provides a set of SQL operators that can be used together with the range data types (see the PostgreSQL documentation for the full details of range operators). This class is meant as a convenient method to avoid typos. The operator names overlap with the names of corresponding lookups.

    class RangeOperators:
        EQUAL = "="
        NOT_EQUAL = "<>"
        CONTAINS = "@>"
        CONTAINED_BY = "<@"
        OVERLAPS = "&&"
        FULLY_LT = "<<"
        FULLY_GT = ">>"
        NOT_LT = "&>"
        NOT_GT = "&<"
        ADJACENT_TO = "-|-"

### Pernyataan RangeBoundary()

class RangeBoundary(inclusive_lower=True, inclusive_upper=False)
  inclusive_lower

    If `True` (default), the lower bound is inclusive `'['`, otherwise it's exclusive `'('`.

  inclusive_upper

    If `False` (default), the upper bound is exclusive `')'`, otherwise it's inclusive `']'`.

A `RangeBoundary()` expression represents the range boundaries. It can be used with a custom range functions that expected boundaries, for example to define `ExclusionConstraint`. See the PostgreSQL documentation for the full details.