django-computed-property icon indicating copy to clipboard operation
django-computed-property copied to clipboard

How to tell whether or not field is computed

Open quantarb opened this issue 6 years ago • 1 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 avatar Nov 21 '18 02:11 quantarb

@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

brechin avatar Nov 29 '18 21:11 brechin