QuerySets still return the model that was requested is wrong/not clear enough
|Reported by:||carsten.klein@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the documentation on models it reads
QuerySets still return the model that was requested
There is no way to have Django return, say, a MyPerson object whenever you query for Person objects. A queryset for Person objects will return those types of objects. The whole point of proxy objects is that code relying on the original Person will use those and your own code can use the extensions you included (that no other code is relying on anyway). It is not a way to replace the Person (or any other) model everywhere with something of your own creation.
I have here a rather complex set up, with a node model class which is not abstract and multiple proxies which represent instances of this node class, for example a document and so on, e.g.
proxy = True
Now, querying document.objects.all() will return an instance of Document and not just Node. However, querying Node.objects.all() will of course return an instance of Node and not an instance of Document.
It seems as if the above quoted paragraph needs some work, since the behaviour experienced when using proxies and their inherited managers and their querysets is different based on which manager you are using to query data from the database. Yet, when reading the above paragraph, one might come to the believe that querying would never return the proxy class, regardless of whether you were using the Document proxy model's manager or the manager of the Node model.