Reputation: 10765
Given a django class and a field name how can you test to see whether the class has a field with the given name?
The field name is a string in this case.
Upvotes: 0
Views: 71
Reputation: 1553
For example:
field_name_exists = field_name in ModelName._meta.get_all_field_names()
Upvotes: 1