Answer the question
In order to leave comments, you need to log in
How to specify the type of records in Django QuerySet in Python type hints?
Is it possible, using Type Hints in Python, to specify the type of entries in a Django QeurySet? Something like QuerySet(SomeModel)
?
For example, we have a model:
class SomeModel(models.Model):
smth = models.IntegerField()
def somefunc(rows: QuerySet):
pass
def somefunc(rows: List[SomeModel]):
pass
Answer the question
In order to leave comments, you need to log in
At the moment this is not possible.
Here is the relevant ticket - https://github.com/python/mypy/issues/1310
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question