I've got two models:
class Company(models.Model):
...
class Supplier(models.Model):
company = models.ForeignKey(Company, null=True, related_name="suppliers")
How to get all Companies with their related Suppliers?
I've tried:
Company.objects.prefetch_related('suppliers')
Company.objects.prefetch_related('supplier_set')
Company.objects.prefetch_related('suppliers').all()
...
What I'm doing wrong?
Thank you
select_related('suppliers')
, however I get:django.core.exceptions.FieldError: Invalid field name(s) given in select_related: 'suppliers'. Choices are: (none)
– Sacco