thanks

On Dec 21, 11:44 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Fri, 2008-12-19 at 19:58 -0800,Shuge Leewrote:
>
> [...]
>
> It's not really necessary to post all that SQL and Python, since you're
> only really asking about a couple of the models. If you can reduce your
> example to the smallest case possible, it's easier for everybody to read
> (just a tip).
>
> > how to do following querying in Django 1.0 ?
>
> > mysql> select product.name, os.name from product inner join os where
> > product.id = os.id ;
> > +-------------+---------+
> > | name        | name    |
> > +-------------+---------+
> > | MS Word     | All     |
> > | Open Office | Windows |
> > +-------------+---------+
> > 2 rows in set (0.02 sec)
>
> So you are after *all* the product names and their associated os names.
> All the product objects is
>
>         Product.objects.all()
>
> That will return you a sequence of Product objects. But if you only want
> the product names, you could use the values() call:
>
>         Product.objects.values('name', 'os__name')
>
> That is documented 
> here:http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to