Upgrade to django 1.10.x: Replace deprecated model._meta methods

This commit is contained in:
Marc Aymerich 2016-10-11 10:21:48 +00:00
parent ec53d357f6
commit 47cf15a000
2 changed files with 7 additions and 2 deletions

View File

@ -290,7 +290,7 @@ class AccountAdminMixin(object):
formfield.queryset = formfield.queryset.filter(account=self.account) formfield.queryset = formfield.queryset.filter(account=self.account)
# Apply heuristic order by # Apply heuristic order by
if not formfield.queryset.query.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: if 'name' in related_fields:
formfield.queryset = formfield.queryset.order_by('name') formfield.queryset = formfield.queryset.order_by('name')
elif 'username' in related_fields: elif 'username' in related_fields:

View File

@ -91,7 +91,12 @@ class Account(auth.AbstractBaseUser):
self.notify_related() self.notify_related()
def get_services_to_disable(self): 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) source = getattr(rel, 'related_model', rel.model)
if source in services and hasattr(source, 'active'): if source in services and hasattr(source, 'active'):
for obj in getattr(self, rel.get_accessor_name()).all(): for obj in getattr(self, rel.get_accessor_name()).all():