[Django]-Django's Double Underscore

20πŸ‘

βœ…

It’s a Django thing, implemented with some Python things.

In Python, you can get a dictionary of the keyword arguments passed to a function or method:

>>> def func(*args, **kwargs):
...     print(kwargs)
>>> func(a=1, b=2)
{'a': 1, 'b': 2}

From there, it can simply iterate over the dictionary keys and split them on __, and then interpret it however it wants. In this case, it takes the last part and interprets icontains as case-insensitive contains.

πŸ‘€icktoofay

Leave a comment