Hi Ryoma, a good way to investigate this would be to make the change and see if anything breaks.
If I understand correctly, your suggest is: - return getattr(self.get_queryset(), name)(*args, **kwargs) + return method(*args, **kwargs) In that case, running the test suite gives this error: File "/home/tim/code/django/django/db/models/manager.py", line 89, in manager_method return method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ TypeError: QuerySet.using() missing 1 required positional argument: 'alias' I leave further investigation to you. :-) On Tuesday, February 27, 2024 at 7:28:05 PM UTC-5 Ryoma Han wrote: > I've been reading through the Django source code the last few days. When I > was reading the BaseManager source code I saw a method like this: > > ```python > @classmethod > def _get_queryset_methods(cls, queryset_class): > def create_method(name, method): > @wraps(method) > def manager_method(self, *args, **kwargs): > return getattr(self.get_queryset(), name)(*args, **kwargs) > > return manager_method > > new_methods = {} > for name, method in inspect.getmembers( > queryset_class, predicate=inspect.isfunction > ): > if hasattr(cls, name): > continue > queryset_only = getattr(method, "queryset_only", None) > if queryset_only or (queryset_only is None and > name.startswith("_")): > continue > new_methods[name] = create_method(name, method) > return new_methods > ``` > > My question is why we use `getattr(self.get_queryset(), name)` insted of > just use `method`. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/86389eb3-c16f-42d6-ae0d-983038734598n%40googlegroups.com.