Hi guys, hope you can help me. 
I have 2 models and i want to make a count query on them. I need a count on 
how many articles i have in every category.

Models:
class Vendors(models.Model):
    id = models.AutoField(db_column='id', primary_key=True, blank=False, 
unique=True)
    name = models.CharField(db_column='name', max_length=150, blank=True, 
null=True)
    groupid = models.IntegerField(db_column='groupid', blank=True, 
null=True)


class VendorGroup(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True, null=False, 
max_length=255, blank=True)
    vendor_group = models.CharField(db_column='Vendor Group', 
max_length=255, blank=True, null=True)

view:
def vendorsgrouping_view(request):
list_vendor = VendorGroup.objects.all().order_by('vendor_group')

context = {
'lista_vendora':lista_vendora, 
}
return render(request, "templates/vendorgroup.html", context)

I have list of vendors listed in template:
    {% for item in lista_vendora %}
        {{ item.vendor_group }}
    {% endfor %}

Prefetch, annotate, select related dont work since they are not connected. 
I know it is easier to give foreign key to fields but what about this?

Thanks,

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f0413341-91b2-4308-afd5-ae486b09a71e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to