> I made a patch for Django to add QuerySet.fields(*fields,
> **related_fields) and make possible to load only some from master and
> related models fields. It allows to tune various object list queries
> when we need only limited subset of all fields, improve general
> performance and decrease database load.

Of course, this decreases database load, but IMHO it is better to use
QuerySet.values if you want select just certain values from a model.

> As side effect of this patch
> support of selecting fields from related models in QuerySet.values()
> is implemented too. It was changed signature of this method from
> values(*fields) to values(*fields, **related_fields) but the change is
> backward compatible.

That QuerySet.values can not select values from related fields, annoys
myself, too. But your implementation is  a bit restricted. Here
the example from your blog:

entries = Entry.objects.values('headline', user=('username',))[:10]

A syntax as following would be more straight forward:

entries = Entry.objects.values('headline', 'user__username')[:10]

At first this is the way other methods of the QuerySet as filter for
example selects related fields and furthermore this would enable to
select the related field of a related field, as QuerySet.filter can do.

Regards
Sebastian Noack

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to