django/django — pull request #317 by anton-ryzhov (2012-09-02 20:50:33+00:00)
Title: Custom QuerySets without creating custom Manager

In the official documentation written:
> You can override a Manager's base QuerySet by overriding the Manager.get_query_set() method. get_query_set() should return a QuerySet with the properties you require.

But it is so strange to override Manager just for changing QuerySet. Hardcoding classnames into Manager class seems non-pythonic way, but I expect there is some reason for such architecture. But I couldn't find this reason.

I'm offering this patch to make Manager more flexible. Small demonstration in unittest:
```python
class User(models.Model):
firstname = models.CharField(max_length=10)
middlename = models.CharField(max_length=10)
lastname = models.CharField(max_length=10)

objects = models.Manager(QuerySetClass=UserQuerySet) # Custom QuerySet in old Manager
```

This is useful for appending QuerySet with methods like `to_json`, which returns list of dicts.