django: CheckboxMultiSelect problem with db queries
Posted
by xiackok
on Stack Overflow
See other posts from Stack Overflow
or by xiackok
Published on 2010-03-29T21:49:28Z
Indexed on
2010/03/29
21:53 UTC
Read the original article
Hit count: 598
firstly sorry for my bad english
there is a simple model Person. That contains just languages:
LANGUAGE_LIS = (
(1, 'English'),
(2, 'Turkish'),
(3, 'Spanish')
)
class Person(models.Model):
languages = models.CharField(max_length=100, choices=LANGUAGE_LIST)
#languages is multi value (CheckBoxSelectMultiple)
and here person_save_form:
class person_save_form(forms.ModelForm):
languages = forms.CharField(widget=forms.CheckBoxSelectMultiple(choices=LANGUAGE_LIST))
class Meta:
model = Person
it is ok. but how can i search persons for languages like "get persons who knows turkish and english"
in the database (MySQL) record "languages" column seen like "[u'1', u'2']". but i want search persons like this:
persons = Person.objects.filter(languages__in=request.POST.getlist('languages'))
© Stack Overflow or respective owner