Skip to content

Commit

Permalink
related_name is Optional[str] (typeddjango#176)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PeterJCLaw authored and mkurnikov committed Sep 23, 2019
1 parent c69090e commit d3dca5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django-stubs/db/models/fields/related.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...,
Expand Down Expand Up @@ -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 = ...,
Expand Down

0 comments on commit d3dca5b

Please sign in to comment.