I have seen a lot of talk about aggregation 1.1, but I'm not sure how to use it to complete a simple group.
I am trying to use the Django Sitemap framework to create a sitemap.xml file that Google can crawl to find all the pages of my site. I am currently passing all objects as in Model.objects.all(), but all that really matters is that only 1 is transferred to the name. There may be 5-10 instances of the model with the same name, but I only want to pass them in order to avoid duplication.
If I do something like this:
Model.objects.values('name').annotate(Count('name'))
It gives me what I want, but then I do not extract all the fields from the model - then the code that creates the site map will be forced to re-request the creation of a link for each individual model. So, how do I get it to group by name when retrieving all the fields of the model?
source
share