From 47cf15a00012359233e1a26f941bd157d137e6b9 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Tue, 11 Oct 2016 10:21:48 +0000 Subject: [PATCH] Upgrade to django 1.10.x: Replace deprecated model._meta methods --- orchestra/contrib/accounts/admin.py | 2 +- orchestra/contrib/accounts/models.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/orchestra/contrib/accounts/admin.py b/orchestra/contrib/accounts/admin.py index ed40d19b..b2e7973b 100644 --- a/orchestra/contrib/accounts/admin.py +++ b/orchestra/contrib/accounts/admin.py @@ -290,7 +290,7 @@ class AccountAdminMixin(object): formfield.queryset = formfield.queryset.filter(account=self.account) # Apply heuristic order by if not formfield.queryset.query.order_by: - related_fields = db_field.related_model._meta.get_all_field_names() + related_fields = [f.name for f in db_field.related_model._meta.get_fields()] if 'name' in related_fields: formfield.queryset = formfield.queryset.order_by('name') elif 'username' in related_fields: diff --git a/orchestra/contrib/accounts/models.py b/orchestra/contrib/accounts/models.py index 1fd8484d..de5214f7 100644 --- a/orchestra/contrib/accounts/models.py +++ b/orchestra/contrib/accounts/models.py @@ -91,7 +91,12 @@ class Account(auth.AbstractBaseUser): self.notify_related() def get_services_to_disable(self): - for rel in self._meta.get_all_related_objects(): + related_fields = [ + f for f in self._meta.get_fields() + if (f.one_to_many or f.one_to_one) + and f.auto_created and not f.concrete + ] + for rel in related_fields: source = getattr(rel, 'related_model', rel.model) if source in services and hasattr(source, 'active'): for obj in getattr(self, rel.get_accessor_name()).all():