class Url(models.Model):
subdomain = models.ForeignKey(Subdomain, null=True, blank=True, related_name='url_subdomain', on_delete=models.SET_NULL,db_index=True)
full_url = models.CharField(max_length=1000, unique=True, db_index=True)
class Meta:
ordering = ['full_url']
def __str__(self):
return self.full_urlsubdomains = Subdomain.objects.all().annotate(numItems=Count('url_subdomain')).order_by('name')SELECT "urls_subdomain"."id", "urls_subdomain"."created_at", "urls_subdomain"."name", COUNT("urls_url"."id") AS "numItems" FROM "urls_subdomain" LEFT OUTER JOIN "urls_url" ON ("urls_subdomain"."id" = "urls_url"."subdomain_id") GROUP BY "urls_subdomain"."id" ORDER BY "urls_subdomain"."name" ASC{% if subdomains %}
<div id="step-filter-tag" class="mb4">
<div class="b mb3">Subdomain</div>
<div class="overflow-auto" style="max-height: 16rem;">
{% for item in subdomains %}
item
{% endfor %}
</div>
</div>
{% endif %}--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/83c9f9a3-1a14-4729-b2cb-3abeb06a8b2fo%40googlegroups.com.
2>SQL QuerySELECT "urls_subdomain"."id", "urls_subdomain"."created_at", "urls_subdomain"."name", COUNT("urls_url"."id") AS "numItems" FROM "urls_subdomain" LEFT OUTER JOIN "urls_url" ON ("urls_subdomain"."id" = "urls_url"."subdomain_id") GROUP BY "urls_subdomain"."id" ORDER BY "urls_subdomain"."name" ASC
--Roger Gammans <rgam...@gammascience.co.uk>
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
GROUP BY is present, or any aggregate functions are present, it is not valid for the SELECT list expressions to refer to ungrouped columns except within aggregate functions or when the ungrouped column is functionally dependent on the grouped columns, since there would otherwise be more than one possible value to return for an ungrouped column. A functional dependency exists if the grouped columns (or a subset thereof) are the primary key of the table containing the ungrouped column.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8ab2bcac-7f72-45e4-82c2-10f9cad5d8e2o%40googlegroups.com.