Select distinct values from a table field

Posted by alj on Stack Overflow See other posts from Stack Overflow or by alj
Published on 2010-03-17T22:56:31Z Indexed on 2010/03/17 23:01 UTC
Read the original article Hit count: 213

Filed under:
|

I'm struggling getting my head around the Django's ORM. What I want to do is get a list of distinct values within a field on my table .... the equivalent of one of the following:

SELECT DISTINCT myfieldname FROM mytable

(or alternatively)

SELECT myfieldname FROM mytable GROUP BY myfieldname

I'd at least like to do it the Django way before resorting to raw sql.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-queryset