Felix Meziere
Felix Meziere
@flaeppe sorry for the delayed response, I've been battling with this trying to apply the docs as well as possible (and other custom techniques to try and make it work)...
@flaeppe Manager methods return a queryset. Let's say I define: ```py class HostingAdvertManager(models.Manager[HostingAdvert]): def filter_by_is_active(self) -> QuerySet[HostingAdvert]: return self.filter(onboarding_status='DONE', is_cool=True) def annotate_with_is_available(self) -> QuerySet[WithAnnotations[HostingAdvert, TypedDict(...)]]: return self.annotate(is_available=Exists(...)) class HostingAdvert(models.Model): ......
@flaeppe sorry but I just amended my previous post for it to be much bigger and complete 😅 do you mind re-reading it and maybe amending yours if anything needs...
@flaeppe one point regarding your answer: you have written: ```py class HostingAdvertManager(models.Manager[HostingAdvert]): def filter_by_is_active(self) -> HostingAdvertManager: ... ``` This allows me to chain things in terms of typing (but without...
@flaeppe yes my issue boils down to: (but generally usage of TypeVar with this manager/queryset typing has a lot of bugs and also I don't get IDE autocomplete anymore that...
@ljodal thanks a LOT for the "typing the self type" tip, I had never thought of this technique, I'm going to try it out todays see if it unlocks some...
Hi! Any work planned on this?
I am badly blocked by this issue (how WithAnnotations doesn't play nice with TypeVars and creating custom Managers/QuerySets etc). WithAnnotations is a time-losing honeypot at the moment
See https://github.com/typeddjango/django-stubs/issues/1046 and https://github.com/typeddjango/django-stubs/issues/1049
I have the same issue! Really a bummer in terms of productivity :/