@@ -8,12 +8,13 @@ Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
88``ArrayField ``
99--------------
1010
11- .. class :: ArrayField(base_field, max_size=None, **options)
11+ .. class :: ArrayField(base_field, max_size=None, size=None, **options)
1212
1313 A field for storing lists of data. Most field types can be used, and you
1414 pass another field instance as the :attr: `base_field
1515 <ArrayField.base_field> `. You may also specify a :attr: `max_size
16- <ArrayField.max_size> `. ``ArrayField `` can be nested to store
16+ <ArrayField.max_size> ` and :attr: `size
17+ <ArrayField.size> `. ``ArrayField `` can be nested to store
1718 multi-dimensional arrays.
1819
1920 If you give the field a :attr: `~django.db.models.Field.default `, ensure
@@ -50,9 +51,13 @@ Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
5051 board = ArrayField(
5152 ArrayField(
5253 models.CharField(max_length=10, blank=True),
53- max_size =8,
54+ size =8,
5455 ),
55- max_size=8,
56+ size=8,
57+ )
58+ active_pieces = ArrayField(
59+ models.CharField(max_length=10, blank=True),
60+ max_size=32
5661 )
5762
5863 Transformation of values between the database and the model, validation
@@ -66,6 +71,18 @@ Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
6671 If passed, the array will have a maximum size as specified, validated
6772 only by forms.
6873
74+ .. attribute :: size
75+
76+ This is an optional argument.
77+
78+ If passed, the array will have size as specified, validated
79+ only by forms.
80+
81+ .. note ::
82+
83+ Defining both ``size `` and ``max_size `` will raise an exception.
84+ Use ``size `` for fixed-length arrays and ``max_size `` for variable-length arrays with an upper limit.
85+
6986Querying ``ArrayField ``
7087~~~~~~~~~~~~~~~~~~~~~~~
7188
0 commit comments