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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/dabd7e85-af77-42b2-9609-71608f923089n%40googlegroups.com.