On Fri, 15 Feb 2008 21:30:23 +1100
Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:

> There's also the fairly pragmatic side-effect that if you are only
> pulling back a very few fields, there isn't really a lot your model
> methods are going to be able to do without loading more data, unless
> they're very simple. You might as well just write those methods as
> functions which take a dictionary and use values() for the cases when
> only two or three items are needed. 

I agree completely, as it is nearly the same I said in my last comment
on this thread.

> > > 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]
> > 
> > I used standard Django lookup syntax, but because in trunk Djnago
> > don't support selecting of related fields, I thought it's better to
> > respect DRY principe and write:
> > entries = Entry.objects.values('headline', user__address=('country',
> > 'city', 'zip'))
> 
> This isn't "standard Django lookup syntax", though. It's some entirely
> new lookup syntax you created. There's nowhere in the current lookup
> hierarchy that uses this method for referring to fields in another
> model. Reusing the existing syntax makes more sense. It's less for
> people to learn and it's less restrictive: with the double-underscore
> syntax, I can list the fields in any order, since they're all
> positional arguments. Your syntax has normal fields as positional
> arguments (so they must come first) and related fields as keyword
> arguments that take a sequence.
> 
> > Also please note, currently lookups with 2 underscores are used only
> > in **kwargs, because it don't have many sense as quoted string (even
> > current QuerySet.order_by() uses '.' instead of '__' as separator).
> 
> Well, that information's a little old (if you're going to be writing
> code in the query construction are of Django, you also need to keep up
> with the branch work that's rewriting large portions of that area;
> that was already mentioned in the related-values ticket before you
> started working on it). Let's not use the current cross-model
> ordering syntax as an example. It's a bit of a wart in the design
> (Database table name + model field attribute name... it's mixing
> apples and oranges). In queryset-refactor, we've changed that
> (order-by) use double-underscores and only field names, just as in
> filters. One of the reasons for this was consistency.
> 
> I think, as Sebastian suggested (and I mentioned in the comment to the
> ticket on related values lookup a few months bcak), we should also use
> double underscores for selecting related values. That makes everything
> nice and consistent across the board.

In my previous message, I said that I agree with Dima's comment, but
that was just because I trusted that it is true that this syntax is
already used in django, without looking at the source. I don't care
much, how the syntax should look like, but it have to enable selecting
related fields from related fields and it should be the same syntax used
in the rest of django's API.


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