forked from typeddjango/djangorestframework-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfields.pyi
719 lines (675 loc) · 24.5 KB
/
fields.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
import datetime
import uuid
from _typeshed import Incomplete
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
from decimal import Decimal
from enum import Enum
from json import JSONDecoder, JSONEncoder
from logging import Logger
from re import Pattern
from typing import Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar
from django.core.files.base import File
from django.db import models
from django.forms import ImageField as DjangoImageField # noqa: F401
from django_stubs_ext import StrOrPromise
from rest_framework.serializers import BaseSerializer
from rest_framework.validators import Validator
from typing_extensions import Self, TypeAlias
logger: Logger
class _Empty(Enum):
sentinel = 0
empty: Final = _Empty.sentinel
class BuiltinSignatureError(Exception): ...
class CreateOnlyDefault:
requires_context: bool
default: Any
def __init__(self, default: Any) -> None: ...
def __call__(self, serializer_field: Field) -> Incomplete: ...
class CurrentUserDefault:
requires_context: bool
def __call__(self, serializer_field: Field) -> Incomplete: ...
class SkipField(Exception): ...
class Option(Protocol):
start_option_group: bool
end_option_group: bool
label: StrOrPromise
value: str
display_text: StrOrPromise
def is_simple_callable(obj: Callable) -> bool: ...
def get_attribute(instance: Any, attrs: list[str] | None) -> Any: ...
def to_choices_dict(choices: Iterable[Any]) -> dict: ...
def flatten_choices_dict(choices: dict[Any, Any]) -> dict: ...
def iter_options(
grouped_choices: dict, cutoff: int | None = ..., cutoff_text: StrOrPromise | None = ...
) -> Generator[Option, None, None]: ...
def get_error_detail(exc_info: Any) -> Any: ...
REGEX_TYPE: Pattern
NOT_READ_ONLY_WRITE_ONLY: str
NOT_READ_ONLY_REQUIRED: str
NOT_REQUIRED_DEFAULT: str
USE_READONLYFIELD: str
MISSING_ERROR_MESSAGE: str
_IN = TypeVar("_IN") # Instance Type
_VT = TypeVar("_VT") # Value Type
_DT = TypeVar("_DT") # Data Type
_RP = TypeVar("_RP") # Representation Type
class SupportsToPython(Protocol):
def to_python(self, value: Any) -> Any: ...
_DefaultInitial: TypeAlias = _VT | Callable[[], _VT] | None | _Empty
class Field(Generic[_VT, _DT, _RP, _IN]):
allow_null: bool
default: _VT | None
default_empty_html: Any
default_error_messages: ClassVar[dict[str, StrOrPromise]]
default_validators: list[Validator[_VT]]
error_messages: dict[str, StrOrPromise]
field_name: str | None
help_text: StrOrPromise | None
initial: _VT | Callable[[], _VT] | None
label: StrOrPromise | None
parent: BaseSerializer
read_only: bool
required: bool
source: Callable | str | None
source_attrs: list[str]
style: dict[str, Any]
write_only: bool
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[_VT] = ...,
initial: _DefaultInitial[_VT] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[_VT]] | None = ...,
allow_null: bool = ...,
) -> None: ...
def __class_getitem__(cls, *args: Any, **kwargs: Any) -> type[Self]: ...
def bind(self, field_name: str, parent: BaseSerializer) -> None: ...
@property
def validators(self) -> list[Validator[_VT]]: ...
@validators.setter
def validators(self, validators: list[Validator[_VT]]) -> None: ...
def get_validators(self) -> list[Validator[_VT]]: ...
def get_initial(self) -> _VT | None: ...
def get_value(self, dictionary: Mapping[Any, Any]) -> Any: ...
def get_attribute(self, instance: _IN) -> _RP | None: ...
def get_default(self) -> _VT | None: ...
def validate_empty_values(self, data: Any) -> tuple[bool, Any]: ...
def run_validation(self, data: Any = ...) -> Any: ...
def run_validators(self, value: Any) -> None: ...
def to_internal_value(self, data: _DT) -> _VT: ...
def to_representation(self, value: _VT) -> _RP: ...
def fail(self, key: str, **kwargs: Any) -> NoReturn: ...
@property
def root(self) -> BaseSerializer: ...
@property
def context(self) -> dict[str, Any]: ...
def __new__(cls, *args: Any, **kwargs: Any) -> Self: ...
def __deepcopy__(self, memo: Mapping[Any, Any]) -> Field: ...
class BooleanField(
Field[
bool,
str | bool | int,
bool,
Any,
]
):
TRUE_VALUES: set[str | bool | int]
FALSE_VALUES: set[str | bool | int | float]
NULL_VALUES: set[str | None]
class NullBooleanField(
Field[
bool | None,
str | bool | int | None,
bool,
Any,
]
):
TRUE_VALUES: set[str | bool | int]
FALSE_VALUES: set[str | bool | int | float]
NULL_VALUES: set[str | None]
class CharField(Field[str, str, str, Any]):
allow_blank: bool
trim_whitespace: bool
max_length: int | None
min_length: int | None
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[StrOrPromise] = ...,
initial: _DefaultInitial[str] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[str]] | None = ...,
allow_null: bool = ...,
allow_blank: bool = ...,
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
) -> None: ...
class EmailField(CharField): ...
class RegexField(CharField):
def __init__(
self,
regex: str | Pattern[str],
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[StrOrPromise] = ...,
initial: _DefaultInitial[str] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[str]] | None = ...,
allow_null: bool = ...,
allow_blank: bool = ...,
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
) -> None: ...
class SlugField(CharField):
allow_unicode: bool
def __init__(
self,
allow_unicode: bool = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[StrOrPromise] = ...,
initial: _DefaultInitial[str] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[str]] | None = ...,
allow_null: bool = ...,
allow_blank: bool = ...,
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
) -> None: ...
class URLField(CharField): ...
class UUIDField(Field[uuid.UUID, uuid.UUID | str | int, str, Any]):
valid_formats: Sequence[str]
uuid_format: str
def __init__(
self,
*,
format: str | None = ...,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[uuid.UUID] = ...,
initial: _DefaultInitial[uuid.UUID] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[uuid.UUID]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class IPAddressField(CharField):
protocol: str
unpack_ipv4: bool
def __init__(
self,
protocol: str = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[str] = ...,
initial: _DefaultInitial[str] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[str]] | None = ...,
allow_null: bool = ...,
allow_blank: bool = ...,
trim_whitespace: bool = ...,
max_length: int = ...,
min_length: int | None = ...,
) -> None: ...
class IntegerField(Field[int, float | int | str, int, Any]):
MAX_STRING_LENGTH: int
re_decimal: Pattern
max_value: int | None
min_value: int | None
def __init__(
self,
*,
max_value: int = ...,
min_value: int = ...,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[int] = ...,
initial: _DefaultInitial[int] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[int]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class FloatField(Field[float, float | int | str, str, Any]):
MAX_STRING_LENGTH: int
re_decimal: Pattern
max_value: float | None
min_value: float | None
def __init__(
self,
*,
max_value: float = ...,
min_value: float = ...,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[float] = ...,
initial: _DefaultInitial[float] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[float]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
MAX_STRING_LENGTH: int
max_digits: int | None
decimal_places: int | None
coerce_to_string: bool | None
max_value: Decimal | int | float | None
min_value: Decimal | int | float | None
localize: bool
rounding: str | None
normalize_output: bool
max_whole_digits: int | None
def __init__(
self,
max_digits: int | None,
decimal_places: int | None,
coerce_to_string: bool | None = None,
max_value: Decimal | int | float | None = None,
min_value: Decimal | int | float | None = None,
localize: bool = ...,
rounding: str | None = None,
normalize_output: bool = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[Decimal] = ...,
initial: _DefaultInitial[Decimal] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Decimal]] | None = ...,
allow_null: bool = ...,
) -> None: ...
def validate_precision(self, value: Decimal) -> Decimal: ...
def quantize(self, value: Decimal) -> Decimal: ...
class DateTimeField(Field[datetime.datetime, datetime.datetime | str, str, Any]):
datetime_parser: Callable[[str, str], datetime.datetime]
format: str | None
input_formats: Sequence[str]
timezone: datetime.tzinfo
def __init__(
self,
format: str | None | _Empty = ...,
input_formats: Sequence[str] | None = None,
default_timezone: datetime.tzinfo | None = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[datetime.datetime] = ...,
initial: _DefaultInitial[datetime.datetime] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[datetime.datetime]] | None = ...,
allow_null: bool = ...,
) -> None: ...
def enforce_timezone(self, value: datetime.datetime) -> datetime.datetime: ...
def default_timezone(self) -> str | None: ...
class DateField(Field[datetime.date, datetime.date | str, str, Any]):
datetime_parser: Callable[[str, str], datetime.datetime]
format: str | None
input_formats: Sequence[str]
def __init__(
self,
format: str | None | _Empty = ...,
input_formats: Sequence[str] | None = None,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[datetime.date] = ...,
initial: _DefaultInitial[datetime.date] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[datetime.date]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class TimeField(Field[datetime.time, datetime.time | str, str, Any]):
datetime_parser: Callable[[str, str], datetime.datetime]
format: str | None
input_formats: Sequence[str]
def __init__(
self,
format: str | None | _Empty = ...,
input_formats: Sequence[str] | None = None,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[datetime.time] = ...,
initial: _DefaultInitial[datetime.time] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[datetime.time]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class DurationField(Field[datetime.timedelta, datetime.timedelta | str, str, Any]):
max_value: datetime.timedelta | None
min_value: datetime.timedelta | None
def __init__(
self,
*,
max_value: datetime.timedelta | int | float = ...,
min_value: datetime.timedelta | int | float = ...,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[datetime.timedelta] = ...,
initial: _DefaultInitial[datetime.timedelta] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[datetime.timedelta]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class ChoiceField(Field[str, str | int | tuple[str | int, str | int | tuple], str, Any]):
html_cutoff: int | None
html_cutoff_text: StrOrPromise | None
allow_blank: bool
grouped_choices: dict
choice_strings_to_values: dict[str, Any]
_choices: dict
def __init__(
self,
choices: Iterable[Any],
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[StrOrPromise | int] = ...,
initial: _DefaultInitial[str | int] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
html_cutoff: int = ...,
html_cutoff_text: StrOrPromise = ...,
allow_blank: bool = ...,
) -> None: ...
def iter_options(self) -> Iterable[Option]: ...
def _get_choices(self) -> dict[Any, Any]: ...
def _set_choices(self, choices: Iterable[Any]) -> None: ...
choices = property(_get_choices, _set_choices)
class MultipleChoiceField(
ChoiceField,
Field[
str,
Sequence[str | int | tuple[str | int, str | int]],
Sequence[str | tuple[str | int, str | int]],
Any,
],
):
allow_empty: bool
def __init__(
self,
*,
choices: Iterable[Any],
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[set[str | int] | set[str] | set[int]] = ...,
initial: _DefaultInitial[set[StrOrPromise | int] | set[StrOrPromise] | set[int]] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
html_cutoff: int = ...,
html_cutoff_text: StrOrPromise = ...,
allow_blank: bool = ...,
allow_empty: bool = ...,
) -> None: ...
class FilePathField(ChoiceField):
def __init__(
self,
path: str,
match: str | None = None,
recursive: bool = ...,
allow_files: bool = ...,
allow_folders: bool = ...,
required: bool | None = None,
*,
read_only: bool = ...,
write_only: bool = ...,
default: _DefaultInitial[str] = ...,
initial: _DefaultInitial[str] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
html_cutoff: int = ...,
html_cutoff_text: StrOrPromise = ...,
allow_blank: bool = ...,
) -> None: ...
class FileField(Field[File, File, str | None, Any]): # this field can return None without raising!
max_length: int
allow_empty_file: bool
use_url: bool
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[File] = ...,
initial: _DefaultInitial[File] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[File]] | None = ...,
allow_null: bool = ...,
max_length: int = ...,
allow_empty_file: bool = ...,
use_url: bool = ...,
) -> None: ...
class ImageField(FileField):
_DjangoImageField: SupportsToPython
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[File] = ...,
initial: _DefaultInitial[File] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[File]] | None = ...,
allow_null: bool = ...,
max_length: int = ...,
allow_empty_file: bool = ...,
use_url: bool = ...,
_DjangoImageField: type[SupportsToPython] = ...,
) -> None: ...
class _UnvalidatedField(Field): ...
class ListField(Field[list[Any], list[Any], list[Any], Any]):
child: Field
allow_empty: bool
max_length: int | None
min_length: int | None
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[list[Any]] = ...,
initial: _DefaultInitial[list[Any]] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[list[Any]]] | None = ...,
allow_null: bool = ...,
child: Field = ...,
allow_empty: bool = ...,
max_length: int | None = ...,
min_length: int | None = ...,
) -> None: ...
def run_child_validation(self, data: list[Mapping[Any, Any]]) -> Any: ...
class DictField(Field[dict[Any, Any], dict[Any, Any], dict[Any, Any], Any]):
child: Field
allow_empty: bool
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[dict[Any, Any]] = ...,
initial: _DefaultInitial[dict[Any, Any]] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[dict[Any, Any]]] | None = ...,
allow_null: bool = ...,
child: Field = ...,
allow_empty: bool = ...,
) -> None: ...
def run_child_validation(self, data: Any) -> Any: ...
class HStoreField(DictField):
child: CharField
class JSONField(Field[dict[str, Any] | list[dict[str, Any]], dict[str, Any] | list[dict[str, Any]], str, Any]):
binary: bool
encoder: type[JSONEncoder] | None
decoder: type[JSONDecoder] | None
def __init__(
self,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: _DefaultInitial[Mapping[Any, Any]] = ...,
initial: _DefaultInitial[Mapping[Any, Any]] = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
binary: bool = ...,
encoder: type[JSONEncoder] | None = ...,
decoder: type[JSONDecoder] | None = ...,
) -> None: ...
class ReadOnlyField(Field): ...
class HiddenField(Field): ...
class SerializerMethodField(Field):
method_name: str
def __init__(
self,
method_name: str | None = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: Any = ...,
initial: Any = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
) -> None: ...
class ModelField(Field):
model_field: models.Field
max_length: int
def __init__(
self,
model_field: models.Field,
*,
read_only: bool = ...,
write_only: bool = ...,
required: bool | None = None,
default: Any = ...,
initial: Any = ...,
source: str | None = None,
label: StrOrPromise | None = None,
help_text: StrOrPromise | None = None,
style: dict[str, Any] | None = None,
error_messages: dict[str, StrOrPromise] | None = None,
validators: Sequence[Validator[Any]] | None = ...,
allow_null: bool = ...,
max_length: int = ...,
) -> None: ...