Skip to content

Is there any way for queries to return the actual model instead of Model? #111

Answered by collerek
makupi asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah I noticed it some time ago and I want to update the types with Generics so it should work better. You can open an issue with types update so it won't be missed along other tasks.

As a immediate yet quite ugly solution you can cast the returned instance to proper type like this:

from typing import cast
instance = UserModel.objects.get()
instance = cast(UserModel, instance)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@collerek
Comment options

@collerek
Comment options

Answer selected by collerek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants