You may be able to use prefetch_related to do what you want: it will all depend upon your model structure. select_related is easier, but only follows an fk in one direction.
On Sunday, 20 May 2012 07:12:54 UTC+5:30, Matt Schinckel wrote:
> You may be able to use prefetch_related to do what you want: it will all > depend upon your model structure. select_related is easier, but only > follows an fk in one direction.
> Matt.
> On Sunday, May 20, 2012 12:27:57 AM UTC+9:30, Aditya Sriram M wrote:
>> Hi,
>> again, my models are Customer, Users and Devices.
>> I would like to search by Customer and retrieve all 'select_related' rows >> of all the three models. >> Eg. like this..
> where 'first_name', 'middle_name' etc are properties of the 'User' model.
> Regards, > Aditya
> On Sunday, 20 May 2012 07:12:54 UTC+5:30, Matt Schinckel wrote:
>> You may be able to use prefetch_related to do what you want: it will all >> depend upon your model structure. select_related is easier, but only >> follows an fk in one direction.
>> Matt.
>> On Sunday, May 20, 2012 12:27:57 AM UTC+9:30, Aditya Sriram M wrote:
>>> Hi,
>>> again, my models are Customer, Users and Devices.
>>> I would like to search by Customer and retrieve all 'select_related' >>> rows of all the three models. >>> Eg. like this..
> > where 'first_name', 'middle_name' etc are properties of the 'User' model.
> > Regards,
> > Aditya
> > On Sunday, 20 May 2012 07:12:54 UTC+5:30, Matt Schinckel wrote:
> >> You may be able to use prefetch_related to do what you want: it will all
> >> depend upon your model structure. select_related is easier, but only
> >> follows an fk in one direction.
> >> Matt.
> >> On Sunday, May 20, 2012 12:27:57 AM UTC+9:30, Aditya Sriram M wrote:
> >>> Hi,
> >>> again, my models are Customer, Users and Devices.
> >>> I would like to search by Customer and retrieve all 'select_related'
> >>> rows of all the three models.
> >>> Eg. like this..
On May 20, 9:42 am, Aditya Sriram M <aditya.cr3...@gmail.com> wrote:
> I tried this but it failed? Can you pls correct me?
yes : "it failed" is the worst possible way to describe a problem if
you expect to get some help. If you get an exception and traceback,
please read them carefully, and eventually post them. Else at least
describe the (unexpected) result.
I'm sorry to have to say, but it definitly looks like you just don't
have a clue about how Python and Django work. Please take time to
learn at least Python 101, then do Django tutorial. This should answer
your questions and save everyone time on such issues.