@classmethod
def _product_list(cls):
    """
    return a list containing the one product_id contained in the request URL,
    or a query containing all valid product_ids if not id present in URL
    used to limit the choice of foreign key object to those related to the current product
    """
id = threadlocals.get_current_product()
if id is not None:
    return [id]
else:
    return Product.objects.all().values('pk').query
Как ограничить выбор внешних ключей связанными объектами только в django