Hello, I am a bit stuck on something that I think ought to be really easy (so I am probably being really stupid!).
I am trying to write a view for a model such that I can pass the view (via post data) a (or an unknown) number of fields of that model, and receive back a list of dictionaries of distinct values for those fields and the number of times that combination of values appears. So, suppose the model was for holding data about cars, and it had fields 'manufacturer', 'model', 'fuel_type', 'colour', 'n_of_doors', etc where the fields had appropriate field types (a mixture of different field types), I would want to be able to pass the view for example groupBy=['colour', 'fuel_type'], and it would return a dict of distinct colour/fuel type combinations and how many cars there are in the db with those combinations, eg. [{'colour': 'red', 'fuel_type: 'diesel', 'count': 14}, ...]. To me it seems like the kind of thing you would want to use annotate and Count for, except Count takes one field not multiple fields. I tried using values() to limit the fields, then python to do the counting / distinct bit, but it is annoying because I want to be able to tell it to return the unicode values for foreign keys etc. rather than ids that would then need to be looked up. Also it is way too slow. I am trying to figure a way to do this that is reasonably fast because I am trying to filter a lot of data. Am I missing something? I haven't been using python / django much lately so I am probably thinking the wrong way! Any help would be appreciated :) Em --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---