mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-12 23:16:31 +08:00
Fix base_field type for SimpleArrayField (#1097)
* Fix base_field type for SimpleArrayField * Add test which fails without this change
This commit is contained in:
@@ -13,13 +13,13 @@ from ..utils import prefix_validation_error as prefix_validation_error
|
|||||||
|
|
||||||
class SimpleArrayField(forms.CharField):
|
class SimpleArrayField(forms.CharField):
|
||||||
default_error_messages: _ErrorMessagesT = ...
|
default_error_messages: _ErrorMessagesT = ...
|
||||||
base_field: Type[forms.Field]
|
base_field: forms.Field
|
||||||
delimiter: str
|
delimiter: str
|
||||||
min_length: Optional[int]
|
min_length: Optional[int]
|
||||||
max_length: Optional[int]
|
max_length: Optional[int]
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
base_field: Type[forms.Field],
|
base_field: forms.Field,
|
||||||
*,
|
*,
|
||||||
delimiter: str = ...,
|
delimiter: str = ...,
|
||||||
max_length: Optional[int] = ...,
|
max_length: Optional[int] = ...,
|
||||||
@@ -51,11 +51,11 @@ class SplitArrayWidget(forms.Widget):
|
|||||||
|
|
||||||
class SplitArrayField(forms.Field):
|
class SplitArrayField(forms.Field):
|
||||||
default_error_messages: _ErrorMessagesT = ...
|
default_error_messages: _ErrorMessagesT = ...
|
||||||
base_field: Type[forms.Field]
|
base_field: forms.Field
|
||||||
size: int
|
size: int
|
||||||
remove_trailing_nulls: bool
|
remove_trailing_nulls: bool
|
||||||
def __init__(
|
def __init__(
|
||||||
self, base_field: Type[forms.Field], size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any
|
self, base_field: forms.Field, size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def to_python(self, value: Any) -> Sequence[Any]: ...
|
def to_python(self, value: Any) -> Sequence[Any]: ...
|
||||||
def clean(self, value: Any) -> Sequence[Any]: ...
|
def clean(self, value: Any) -> Sequence[Any]: ...
|
||||||
|
|||||||
@@ -17,3 +17,18 @@
|
|||||||
|
|
||||||
class MyModel(models.Model):
|
class MyModel(models.Model):
|
||||||
array = ArrayField(base_field=models.TextField())
|
array = ArrayField(base_field=models.TextField())
|
||||||
|
- case: postgres_forms_simple_array_field
|
||||||
|
main: |
|
||||||
|
from myapp.forms import MyForm
|
||||||
|
MyForm()
|
||||||
|
installed_apps:
|
||||||
|
- myapp
|
||||||
|
files:
|
||||||
|
- path: myapp/__init__.py
|
||||||
|
- path: myapp/forms.py
|
||||||
|
content: |
|
||||||
|
from django import forms
|
||||||
|
from django.contrib.postgres.forms import SimpleArrayField
|
||||||
|
|
||||||
|
class MyForm(forms.Form):
|
||||||
|
lots_of_dates = SimpleArrayField(forms.DateField(), required=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user