Re: Joining tables
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 <swaroopsv@gmail.com> wrote:
hello All,I have a model of following structureclass ExtraInfomration():I have another model for profile. I need to retrieve users ordered by the popularity from the User model. This is the code am using to retrieve the users listuser = 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 = models.FloatField(_('Popularity'), null=True, blank=True, default=0.0)created_on = models.DateTimeField(auto_now_add = True, null=True)updated_on = models.DateTimeField(auto_now=True)userObject = User.objects.filter(is_active=1,is_staff=0,is_superuser=0)how can i order the data based on the popularity field in extrainformation? ThanksRegards,--
Swaroop Shankar V
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
Digitally,
Arun Prabhakar
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home