Re: Caching back-refernces on one-to-one fields

2012-01-20 Thread Ian Clelland
On Thu, Jan 19, 2012 at 1:27 PM, Adrian Holovaty wrote: > On Thu, Jan 19, 2012 at 12:15 PM, Carl Meyer wrote: > > I don't think Adrian is proposing anything as extensive as #17. What > > he's proposing (IIUC) wouldn't change the semantics of your sample code > > at all. All it would do is prepopu

Re: Caching back-refernces on one-to-one fields

2012-01-19 Thread Adrian Holovaty
On Thu, Jan 19, 2012 at 12:15 PM, Carl Meyer wrote: > I don't think Adrian is proposing anything as extensive as #17. What > he's proposing (IIUC) wouldn't change the semantics of your sample code > at all. All it would do is prepopulate the FK field on the results of a > reverse-FK query, so the

Re: Caching back-refernces on one-to-one fields

2012-01-19 Thread Shai Berger
Hi again, > > john = Author.objects.get(name='john') > books = list(john.book_set.all()) > > # Does a database query, but should be smart enough to simply return john. > books[0].author > """ > > I'm pretty sure there's a long-standing ticket for this, but I'm not > sure which one it is. Shai,

Re: Caching back-refernces on one-to-one fields

2012-01-19 Thread Carl Meyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/19/2012 11:02 AM, Jeremy Dunck wrote: > On Thu, Jan 19, 2012 at 5:14 PM, Adrian Holovaty wrote: >> john = Author.objects.get(name='john') >> books = list(john.book_set.all()) >> >> # Does a database query, but should be smart enough to simply re

Re: Caching back-refernces on one-to-one fields

2012-01-19 Thread Jeremy Dunck
On Thu, Jan 19, 2012 at 5:14 PM, Adrian Holovaty wrote: > On Wed, Jan 18, 2012 at 1:07 PM, Shai Berger wrote: >> I have a small improvement to suggest for one-to-one fields: Make them cache >> back-references on related objects. That is, assume > > Yes! Good improvement. And we should do the same

Re: Caching back-refernces on one-to-one fields

2012-01-19 Thread Adrian Holovaty
On Wed, Jan 18, 2012 at 1:07 PM, Shai Berger wrote: > I have a small improvement to suggest for one-to-one fields: Make them cache > back-references on related objects. That is, assume Yes! Good improvement. And we should do the same thing for one-to-many fields (ForeignKeys): """ class Author(m

Re: Caching back-refernces on one-to-one fields

2012-01-19 Thread Florian Apolloner
Hi, On Wednesday, January 18, 2012 8:07:26 PM UTC+1, Shai Berger wrote: > > Do you see a reason why I should not post a ticket? > No, please go ahead. Funny you mention that problem now, I ran over the same thing yesterday :) Cheers, Florian -- You received this message because you are subscr

Re: Caching back-refernces on one-to-one fields

2012-01-18 Thread Jeremy Dunck
On Wed, Jan 18, 2012 at 11:07 AM, Shai Berger wrote: > Do you see a reason why I should not post a ticket? +1 -- 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 unsu

Caching back-refernces on one-to-one fields

2012-01-18 Thread Shai Berger
Hi Django devs, I have a small improvement to suggest for one-to-one fields: Make them cache back-references on related objects. That is, assume class A(model): pass class B(model): a = OneToOneField(A) a1 = A.objects.get(...) # assume a1 has a related B record