Reputation: 15008
Is there any Django built-in function that return a list of all auto-generated fields from a Django model?
Something like: MyModel._meta._get_auto_generated_fields()
Upvotes: 2
Views: 34
Reputation: 476659
You can filter the fields with list comprehension on the .auto_generated
attribute [Django-doc]:
[field for field in MyModel._meta.get_fields() if field.auto_created]
Upvotes: 2