From 29522aad4e7692aef881f785299618f171422efd Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 6 Aug 2016 11:09:52 +0200 Subject: [PATCH] Usage of the documented API for models _meta --- cas_server/auth.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cas_server/auth.py b/cas_server/auth.py index ab0c664..81dc37f 100644 --- a/cas_server/auth.py +++ b/cas_server/auth.py @@ -369,8 +369,16 @@ class DjangoAuthUser(AuthUser): # pragma: no cover """ if self.user: attr = {} - for field in self.user._meta.fields: - attr[field.attname] = getattr(self.user, field.attname) + # _meta.get_fields() is from the new documented _meta interface in django 1.8 + try: + field_names = [ + field.attname for field in self.user._meta.get_fields() if hasattr(field, "attname") + ] + # backward compatibility with django 1.7 + except AttributeError: # pragma: no cover (only used by django 1.7) + field_names = self.user._meta.get_all_field_names() + for name in field_names: + attr[name] = getattr(self.user, name) return attr else: return {}