Ooo.. Nice.

Hmm.. I tried this but it failed? Can you pls correct me?

def queryset(self, request):
        result = super(CustomerAdmin, 
self).queryset(request).prefetch_related()
        return result

and my 'display list' for customer admin is..

list_display = ('get_user_name')

where definition of 'get_user_name' is

def get_user_name(self, obj):
        return u'%s %s %s' % (obj.customerid__first_name, 
obj.customerid__middle_name, obj.customerid__last_name)
get_user_name.short_description = 'User Name' 

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..
>>
>> Customer1 User1 Device1
>> Customer1 User1 Device2
>> Customer1 User2 Device1
>> Customer1 User2 Device2
>> etc etc..
>>
>> Is this possible in Django? If so how?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/D_wJGMaM5UAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to