[Solved]-Django models and Python properties

14👍

Unfortunately, Django models don’t play very nice with Python properties. The way it works, the ORM only recognizes the names of field instances in QuerySet filters.

You won’t be able to refer to summary in your filters, instead you’ll have to use _summary. This gets messy real quick, for example to refer to this field in a multi-table query, you’d have to use something like

User.objects.filter(post___summary__contains="some string")

See https://code.djangoproject.com/ticket/3148 for more detail on property support.

Leave a comment