Hi Alex

I could do almost all query but not the "not equals" could you give me some 
tip to add this operator to my object?

I am doing the following way:

  if (operador == 'equals'):
            d[realname] = value
  elif (operador == greather than'):
            d[realname + '__gt'] = value
        elif (operador == 'less than'):
            d[realname + '__lt'] = value
elif (operador == 'not equals'):
            ????
. . .
qs = classDjango.objects.filter(**d)

    return qf


Best regards
Ezequias
On Wednesday, January 8, 2020 at 10:08:18 PM UTC-3, Alex Conselvan de 
Oliveira wrote:
>
> Hi Ezequias,
>
> You could use a dict:
>
> data = {
>   'name': 'John',
>   'age': 42,
> }
>
> model.filter(**data)
>
> Best Regards!
>
> Em qua., 8 de jan. de 2020 às 18:09, Ezequias Rocha <ezequi...@gmail.com 
> <javascript:>> escreveu:
>
>> Hi everyone
>>
>> I am in a doubt about creating django filters dynamically.
>>
>> All you know a filter is made by using the parameters like:
>>
>> model.filter(name='John', age=42)
>>
>> But if I can't type all fields and values at design time but at runtime 
>> how to do that?
>>
>> Best regards
>> Ezequias
>>
>> -- 
>> 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 django...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9c843d02-235f-411f-8e83-7fea2156893b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/9c843d02-235f-411f-8e83-7fea2156893b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c69bf607-3860-40b0-a12d-dd9623c27cef%40googlegroups.com.

Reply via email to