I'm curious if there's any way to do a query in Django that's not a "
SELECT * FROM..." underneath. I'm trying to do a "
SELECT DISTINCT columnName FROM ..." instead.
Specifically I have a model that looks like:
class ProductOrder(models.Model): Product = models.CharField(max_length=20, promary_key=True) Category = models.CharField(max_length=30) Rank = models.IntegerField()
Rank is a rank within a
Category. I'd like to be able to iterate over all the Categories doing some operation on each rank within that category.
I'd like to first get a list of all the categories in the system and then query for all products in that category and repeat until every category is processed.
I'd rather avoid raw SQL, but if I have to go there, that'd be fine. Though I've never coded raw SQL in Django/Python before.