Karen Tracey wrote:
> On 11/1/07, *George Vilches* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> [snip]
> 
>     For reporting purposes though, we would like to be able to
>     .select_related() on User, and get a cached copy of each of the OneToOne
>     relationships.  It seems reasonable by the very essence of OneToOne, but
>     I don't know if there's some limitation that would prevent that
>     following from happening.  However, when we pull 50 users, having 50*N
>     tables of extra queries when we need data from a few separate places
>     makes the whole task unappealing to use the Django ORM for.  I wouldn't
>     think about asking that this should be in the ORM, except that Django
>     supports reverse foreign keys so intelligently that it seems a direct
>     1:1 correlation between rows is intuitive to go in either direction.
> 
> 
> In the absence of explicit support for the reverse relation on OneToOne 
> fields, can't you use the QuerySet extra() method ( 
> http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none)
>  
> to pull in all the various tables/columns you are interested in in a 
> single query? 

We have used this in a few places already, and it's fine for just 
manipulating the data directly, but we really wanted to have instances 
of the Models themselves populated from that single query.  The models 
have a bunch of nice methods for manipulating the data, and it would be 
annoying to have to manually create instances of 10+ models and insert 
40+ columns of data into them to get to use those helper methods.  Too 
much typing. :)

 > p.s. to the Django website maintainers: pretty favicon!

Agreed, I like it.


George

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to