Making an OR condition in a Queryset using .filter(**mydict)

17 views
Skip to first unread message

Ezequias Rocha

unread,
Jan 10, 2020, 9:23:58 AM1/10/20
to Django users
Hi everyone

I am using a dynamic filter and I am building my own arguments at runtime.

The problem I am focusing is when I want my filter operates as an OR conditional. I am using the following way to do the AND filter

data = {
  'name': 'John',
  'age': 42,
}

model.filter(**data)

It works but all conditions in data dictionary are  treated as an AND operator.

Does anyone knows how to apply the OR (|) condition to this filter?

My best regards
Ezequias Rocha

Sreevardhan Reddy

unread,
Jan 14, 2020, 12:21:48 AM1/14/20
to django...@googlegroups.com

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8f61aabe-9faf-4291-bb7e-4b403ea13e5a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages