Christian Schmitt
Christian Schmitt

Reputation: 892

Check if field is in abstract model class

How can I check if a Model Field is in the abstract model?

I want to write a custom model_to_dict function that, only gives the field of the Abstract Model and not the related model.

So i want to exclude every field that is not in the abstract model, is that even possible?

Upvotes: 0

Views: 130

Answers (1)

Rohan
Rohan

Reputation: 53326

You can try

hasattr(AbstrctModel, 'attr_name1')

If it returns True then its in the model.

Upvotes: 1

Related Questions