Answer the question
In order to leave comments, you need to log in
How to filter queryset by multi select?
I add the ability to select multiple parameters to the search form in the application, I decided to use select multiple, but I don’t know how to filter with multiple values. Please suggest some concise solution. Thank you!
Is it even possible to bind some cool multiselect widget to django and use QuerySet.filter() to filter the list of objects?
Answer the question
In order to leave comments, you need to log in
I did a little crooked, but I did not find another way
class TechniqueGroup(models.Model):
name = models.CharField(max_length=250, verbose_name='Тематика', blank=True, null=True, unique=True)
technique = models.ManyToManyField(Technique, verbose_name='техника', related_name='group', blank=True, )
def grouplist(self):
group = []
for tech in self.technique.all():
group.append(tech.id)
return group
def __str__(self):
return self.name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question