You can pass filter params like a dict -
Player.objects.filter(**your_dict), so you need only prepare your dict from
POST.
8 жовт. 2013 17:42, користувач "Hélio Miranda" <[email protected]> написав:

> Hi
> Here I am having a problem which is as follows:
> I 'm getting parameters via post to make querys depending on paramtros I
> are passed ... doing gender filters.
> So I'm doing well
> *def filter(request):*
> *    if request.method == 'POST':*
> *        namepost = request.POST.get('name')*
> *        surnamepost = request.POST.get('surname')*
> *
> *
> *        if namepost != None and surnamepost != None:*
> *            result = [a.get_json() for a in
> Player.objects.filter((Q(name=namepost) & Q(surname=surnamepost)))]*
> *       elif namepost != None and surnamepost == None:*
> *            result = [a.get_json() for a in
> Player.objects.filter(name=namepost)]*
> *        *
> *        data = {"meta": {"total_count":len(result)}, "objects": result}*
> *        aa = json.dumps(data)*
> *        return HttpResponse(aa, content_type='application/json')*
>
> Is working properly , the problem is :
> If it were only these two parameters , there was no problem , was to
> complete the rest of the hypotheses ... the problem is that I can have up
> to 10 parameters passed by post to the filters , and I never know which are
> passed , can be 1 , 2, 4, ... as the user makes the filter ...
>
> But doing so would take a lot of ifs , it would have many chances ...
> is there any way I can do this another way ?
> Someone can help me ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fc851085-d5bb-4567-b830-d25cdd66e499%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BX6QOXTgDCfXiB_CsqgRjg_V5ngho5gk%3DoZEfP8WhpwfcB2Kg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to