mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-10-17 03:21:30 +08:00
related_name is Optional[str] (#176)
In the current Django (2.1, 2.2), the `related_name` parameter to `OneToOneField` and `ForeignKey` classes (much like `ManyToManyField` and the base `ForeignObject` classes) is `Optional[str]`. While it's true that most authors won't pass `None` here, derived field types will want to be able to do so.
This commit is contained in:
1 parent
c69090ec5b
commit
d3dca5b408
1 file changed
+2
-2
@@ -114,7 +114,7 @@ class ForeignKey(ForeignObject[_ST, _GT]):
|
||||
to: Union[Type[Model], str],
|
||||
on_delete: Callable[..., None],
|
||||
to_field: Optional[str] = ...,
|
||||
related_name: str = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
|
||||
parent_link: bool = ...,
|
||||
@@ -159,7 +159,7 @@ class OneToOneField(RelatedField[_ST, _GT]):
|
||||
to: Union[Type[Model], str],
|
||||
on_delete: Any,
|
||||
to_field: Optional[str] = ...,
|
||||
related_name: str = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
|
||||
parent_link: bool = ...,
|
||||
|
||||
Reference in new issue
Block a user