django_compat.py 567 B

123456789101112131415
  1. from itertools import chain
  2. # https://docs.djangoproject.com/en/1.10/ref/models/meta/#migrating-from-the-old-api
  3. # https://github.com/python-social-auth/social-app-django/commit/65b68d5e47f6990625c19afe8317397bdbbb11cd
  4. def get_all_field_names(model):
  5. return list(
  6. set(
  7. chain.from_iterable(
  8. (field.name, field.attname) if hasattr(field, "attname") else (field.name,)
  9. for field in model._meta.get_fields()
  10. if not (field.many_to_one and field.related_model is None)
  11. )
  12. )
  13. )