-
-
Notifications
You must be signed in to change notification settings - Fork 529
Add django.contrib.postgres.forms* #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from .array import * | ||
| from .hstore import * | ||
| from .jsonb import * | ||
| from .ranges import * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from typing import Any, Iterable, List, Optional, Type, Union | ||
|
|
||
| from django import forms as forms | ||
|
|
||
| class SimpleArrayField(forms.CharField): | ||
| base_field: forms.Field = ... | ||
| delimiter: str = ... | ||
| min_length: Optional[Union[int, str]] = ... | ||
| max_length: Optional[Union[int, str]] = ... | ||
| def __init__( | ||
| self, | ||
| base_field: forms.Field, | ||
| *, | ||
| delimiter: str = ..., | ||
| max_length: Optional[Any] = ..., | ||
| min_length: Optional[Any] = ..., | ||
| **kwargs: Any | ||
| ) -> None: ... | ||
| def to_python(self, value: Optional[Iterable]) -> List: ... | ||
| def validate(self, value: Optional[Iterable]) -> None: ... | ||
| def run_validators(self, value: Optional[Iterable]) -> None: ... | ||
|
|
||
| class SplitArrayWidget(forms.Widget): | ||
| template_name: str = ... | ||
| widget: forms.Widget = ... | ||
| size: int = ... | ||
| def __init__(self, widget: Union[forms.Widget, Type[forms.Widget]], size: int, **kwargs: Any) -> None: ... | ||
| def value_from_datadict(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> List: ... | ||
| def get_context(self, name: Any, value: Any, attrs: Optional[Any] = ...): ... | ||
| @property | ||
| def needs_multipart_form(self) -> bool: ... | ||
|
|
||
| class SplitArrayField(forms.Field): | ||
| base_field: forms.Field = ... | ||
| size: int = ... | ||
| remove_trailing_nulls: bool = ... | ||
| def __init__( | ||
| self, base_field: forms.Field, size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any | ||
| ) -> None: ... | ||
| def to_python(self, value: Optional[Iterable]) -> List: ... | ||
| def clean(self, value: Any) -> List: ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django import forms | ||
|
|
||
| class HStoreField(forms.CharField): ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from django import forms | ||
| from typing import Any, Type, Union | ||
|
|
||
| class InvalidJSONInput(str): ... | ||
| class JSONString(str): ... | ||
|
|
||
| class JSONField(forms.CharField): | ||
| widget: Union[forms.Widget, Type[forms.Widget]] = ... | ||
| def prepare_value(self, value: Any) -> str: ... | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| from django import forms | ||
| from django.forms.widgets import MultiWidget | ||
| from typing import Any, Callable, Optional, Type, Union | ||
|
|
||
| _OptAttrs = Dict[str, Any] | ||
|
|
||
| class BaseRangeField(forms.MultiValueField): | ||
| def __init__(self, **kwargs: Any) -> None: ... | ||
| def compress(self, values: Any) -> Tuple[Optional[Callable], Optional[Callable]]: ... | ||
|
|
||
| class IntegerRangeField(BaseRangeField): | ||
| base_field: Union[Type[forms.Field], forms.Field] = ... | ||
|
||
|
|
||
| class FloatRangeField(BaseRangeField): | ||
| base_field: Union[Type[forms.Field], forms.Field] = ... | ||
|
|
||
| class DateTimeRangeField(BaseRangeField): | ||
| base_field: Union[Type[forms.Field], forms.Field] = ... | ||
|
|
||
| class DateRangeField(BaseRangeField): | ||
| base_field: Union[Type[forms.Field], forms.Field] = ... | ||
|
|
||
| class RangeWidget(MultiWidget): | ||
| def __init__(self, base_widget: forms.Widget, attrs: Optional[_OptAttrs] = ...) -> None: ... | ||
| def decompress(self, value: Any) -> List: ... | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from typing import Mapping | ||
|
|
||
| from django.core.exceptions import ValidationError | ||
|
|
||
| def prefix_validation_error(error: ValidationError, prefix: str, code: str, params: Mapping) -> ValidationError: ... |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in the comment about
base_fieldUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Django is weird ... the field classes expect
widgetto define a static attribute specifying the widget class, but then instantiate and set theself.widgetto the instance in the constuctor 🤦♂ ... so if I pull the above line toforms.FieldI start seeing errors like this:I could only resolve this by pulling defining this in child class:
In that case, I guess it's better to keep the
Unionon the parent, and add theArgument 1 to "render" of "Widget" has incompatible type "str"error under:enabled_test_modules.py?