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:
Peter Law
2019-09-23 15:38:34 +01:00
committed by Maxim Kurnikov
parent c69090ec5b
commit d3dca5b408

View File

@@ -114,7 +114,7 @@ class ForeignKey(ForeignObject[_ST, _GT]):
to: Union[Type[Model], str], to: Union[Type[Model], str],
on_delete: Callable[..., None], on_delete: Callable[..., None],
to_field: Optional[str] = ..., to_field: Optional[str] = ...,
related_name: str = ..., related_name: Optional[str] = ...,
related_query_name: Optional[str] = ..., related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ..., limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
parent_link: bool = ..., parent_link: bool = ...,
@@ -159,7 +159,7 @@ class OneToOneField(RelatedField[_ST, _GT]):
to: Union[Type[Model], str], to: Union[Type[Model], str],
on_delete: Any, on_delete: Any,
to_field: Optional[str] = ..., to_field: Optional[str] = ...,
related_name: str = ..., related_name: Optional[str] = ...,
related_query_name: Optional[str] = ..., related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ..., limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
parent_link: bool = ..., parent_link: bool = ...,