Issues with queryset and slicing

Company is a queryset. You might want to do

Product.objects.filter(company=company[0], pk=product_pk)

Or better yet you can use the relations in the ORM to simplify into 1 lookup.

Product.objects.get(company__account=account, company__pk=company_pk, pk=product_pk) 

As said in the accepted answer, company is a queryset.

The QuerySet value for an exact lookup must be limited to one result using slicing.

Instead of this

product = Product.objects.filter(company=company, pk=product_pk)

try this

product = Product.objects.filter(company__in=company, pk=product_pk)

__in can handle querysets larger than one (multiple records of a table).

This can be found in the django Many-to_one relationships section of the documentation. https://docs.djangoproject.com/en/2.0/topics/db/examples/many_to_one/

Django documentation can be scary for a beginner like me because of its length and depth, though it provides solutions to most issues if you can crack it.