Meta.fields contains a field that isn't defined on this FilterSet: **** Meta.fields contains a field that isn't defined on this FilterSet: **** django django

Meta.fields contains a field that isn't defined on this FilterSet: ****


See this for a good explanation.

When you do queryset.filter(field_name=field_value), Django translates that into a SQL query. Unfortunately, calculated properties only live on the Python object, so you can't filter by them.

The workaround is to, whenever you filter by one of these, include an annotation to your queryset that adds the proper field in SQL. The link has a good example of how to do this. It's harder than doing it in Python, but the only way to go really.