@@ -8,12 +8,13 @@ Some MongoDB-specific fields are available in ``django_mongodb_backend.fields``.
8
8
``ArrayField ``
9
9
--------------
10
10
11
- .. class :: ArrayField(base_field, max_size=None, **options)
11
+ .. class :: ArrayField(base_field, max_size=None, size=None, **options)
12
12
13
13
A field for storing lists of data. Most field types can be used, and you
14
14
pass another field instance as the :attr: `base_field
15
15
<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
17
18
multi-dimensional arrays.
18
19
19
20
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``.
50
51
board = ArrayField(
51
52
ArrayField(
52
53
models.CharField(max_length=10, blank=True),
53
- max_size =8,
54
+ size =8,
54
55
),
55
- max_size=8,
56
+ size=8,
57
+ )
58
+ active_pieces = ArrayField(
59
+ models.CharField(max_length=10, blank=True),
60
+ max_size=32
56
61
)
57
62
58
63
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``.
66
71
If passed, the array will have a maximum size as specified, validated
67
72
only by forms.
68
73
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
+
69
86
Querying ``ArrayField ``
70
87
~~~~~~~~~~~~~~~~~~~~~~~
71
88
0 commit comments