diff --git a/simple_history/models.py b/simple_history/models.py index 6dc4db9e..66d8c64f 100644 --- a/simple_history/models.py +++ b/simple_history/models.py @@ -3,6 +3,7 @@ import uuid import warnings from functools import partial +from typing import TypeVar from django.apps import apps from django.conf import settings @@ -45,6 +46,13 @@ except ImportError: from threading import local as LocalContext + +# __set__ value type +_ST = TypeVar("_ST") +# __get__ return type +_GT = TypeVar("_GT") + + registered_models = {} @@ -873,7 +881,7 @@ def get_queryset(self): ) -class HistoricForeignKey(ForeignKey): +class HistoricForeignKey(ForeignKey[_ST, _GT]): """ Allows foreign keys to work properly from a historic instance.