views:

24

answers:

0

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'))