Answer the question
In order to leave comments, you need to log in
How to create an array filter in django orm?
Given 2 models:
class Country(models.Model):
title = models.CharField(
max_length=120, verbose_name="Наименование"
)
class Product(models.Model):
country = models.ForeignKey(
Country,
on_delete=models.CASCADE,
blank=True
)
Answer the question
In order to leave comments, you need to log in
products = Product.objects.filter(country_id__in=countries_ids)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question