schneck schneck - 5 months ago 21
Python Question

Filter by property

Is it possible to filter by property?

i have a method in my model:

def myproperty(self):

and now i want to filter by this property like:


is this somehow possible?

Answer Source

Nope. Django filters operate at the database level, generating SQL. To filter based on Python properties, you have to load the object into Python to evaluate the property--and at that point, you've already done all the work to load it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download