brechin / django-computed-property

Computed Property Fields for Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to tell whether or not field is computed

quantarb opened this issue · comments

Hello, is there anyway to tell whether or not the field is computed. I am trying to get all the fields that from a model that are primary keys, foreign keys, or computed values. I can get whether or not it is a primary key or foreign key from the meta data. Not sure about the last one.

@quantarb How are you inspecting the fields now?

You could do something like this:

from computed_property import ComputedField

for field in model._meta.fields:
    if isinstance(field, ComputedField):
        # do your thing