Re: Joining tables

2012-01-23 Thread Arun P
@bruno Dint know that you can do lookups from OneToOne related models Thanks On Mon, Jan 16, 2012 at 8:00 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > On Jan 16, 8:04 am, Arun P wrote: > > Does this work? > > > > info = > > > ExtraInformation.objects.filter(user__is_active

Re: Joining tables

2012-01-16 Thread bruno desthuilliers
On Jan 16, 8:04 am, Arun P wrote: > Does this work? > > info = > ExtraInformation.objects.filter(user__is_active=1,user__is_staff=0,user__is_superuser=0).order_by("popularity").select_related("user") > > users = map(lambda i: i.user, info) That was for the "uselessly complicated and memory-hungr

Re: Joining tables

2012-01-15 Thread Arun P
Does this work? info = ExtraInformation.objects.filter(user__is_active=1,user__is_staff=0,user__is_superuser=0).order_by("popularity").select_related("user") users = map(lambda i: i.user, info) Thanks On Sun, Jan 15, 2012 at 1:05 AM, Swaroop Shankar V wrote: > hello All, > I have a model of

Joining tables

2012-01-14 Thread Swaroop Shankar V
hello All, I have a model of following structure class ExtraInfomration(): user = models.OneToOneField(User) total_likes = models.IntegerField(_('Total Likes'), null=True, blank=True, default=0) total_dislikes = models.IntegerField(_('Total Dislikes'), null=True, blank=True, default=0) popularity

Re: Joining Tables

2012-01-08 Thread Swaroop Shankar V
Thanks a lot Anler, that's exactly what I want. I never knew that it was so simple. Thanks and Regards, Swaroop Shankar V On Sun, Jan 8, 2012 at 4:36 PM, Anler wrote: > Oh sorry, it should be this: > > photos = Photos.objects.filter(user__groups__id=the_group_id) > > -- > Anler > Sent with S

Re: Joining Tables

2012-01-08 Thread Anler
Oh sorry, it should be this: photos = Photos.objects.filter(user__groups__id=the_group_id) -- Anler Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Sunday, January 8, 2012 at 12:04 PM, Anler wrote: > Swaroop I think this is what you're asking for: > > photos = Photos.objects.fil

Re: Joining Tables

2012-01-08 Thread Anler
Swaroop I think this is what you're asking for: photos = Photos.objects.filter(user__groups__name='admin') -- Anler Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Sunday, January 8, 2012 at 11:42 AM, Jonas Geiregat wrote: > > > > Thanks Jonas, the statements you had provided wo

Re: Joining Tables

2012-01-08 Thread Jonas Geiregat
> Thanks Jonas, the statements you had provided would give me a list of users > who belong that group, but how can I retrieve the photos of those users? > Actually I was looking for a single statement which would join all these > tables and returns the data based on the Group ID. I would reco

Re: Joining Tables

2012-01-08 Thread Swaroop Shankar V
Thanks Jonas, the statements you had provided would give me a list of users who belong that group, but how can I retrieve the photos of those users? Actually I was looking for a single statement which would join all these tables and returns the data based on the Group ID. Thanks and Regards, Swaro

Re: Joining Tables

2012-01-08 Thread Jonas Geiregat
> The user field is a foreign key to django auth User model. Each user is > assigned to a group (django Auth Group model). I want to retrieve all the > photos which belongs to users of a specific group. How can it be done? > from django.contrib.auth.models import Group group = Group.objects.

Re: Joining Tables

2012-01-08 Thread Jonas Geiregat
> The user field is a foreign key to django auth User model. Each user is > assigned to a group (django Auth Group model). I want to retrieve all the > photos which belongs to users of a specific group. How can it be done? > from django.contrib.auth.models import Group group = Group.objects.

Joining Tables

2012-01-07 Thread Swaroop Shankar V
Hi, I got a models which is as follows: class Photos(models.Model): """ This model will enable the users to upload photos """ user = models.ForeignKey(User) title = models.CharField(_('Title'), max_length=250, null = True, blank = True) description = models.TextField(_('Des