From 59fc9eff18f361a1e1eb56d09f652047ec6185a8 Mon Sep 17 00:00:00 2001 From: jay7958 Date: Thu, 20 Aug 2015 12:53:59 -0500 Subject: [PATCH 1/2] Changed import statement and reference to GenericRelation in order to remove the following Django Warning: site-packages/auditlog/models.py:6: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes. from django.contrib.contenttypes import generic --- src/auditlog/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auditlog/models.py b/src/auditlog/models.py index 13c15b2..739352d 100644 --- a/src/auditlog/models.py +++ b/src/auditlog/models.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import json from django.conf import settings -from django.contrib.contenttypes import generic +from django.contrib.contenttypes.fields import GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models import QuerySet, Q @@ -227,9 +227,9 @@ class LogEntry(models.Model): return separator.join(substrings) -class AuditlogHistoryField(generic.GenericRelation): +class AuditlogHistoryField(GenericRelation): """ - A subclass of py:class:`django.contrib.contenttypes.generic.GenericRelation` that sets some default variables. This + A subclass of py:class:`django.contrib.contenttypes.fields.GenericRelation` that sets some default variables. This makes it easier to access Auditlog's log entries, for example in templates. By default this field will assume that your primary keys are numeric, simply because this is the most common case. From 655e02e8062830804859a073ecc58d76dfe327a7 Mon Sep 17 00:00:00 2001 From: jay7958 Date: Thu, 20 Aug 2015 13:49:22 -0500 Subject: [PATCH 2/2] Changed import to use the new apps module for get_model, this removes the Django warning: site-packages/auditlog/middleware.py:9: RemovedInDjango19Warning: The utilities in django.db.models.loading are deprecated in favor of the new application loading system. from django.db.models.loading import get_model --- src/auditlog/middleware.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auditlog/middleware.py b/src/auditlog/middleware.py index b8bd34b..d6c7d68 100644 --- a/src/auditlog/middleware.py +++ b/src/auditlog/middleware.py @@ -6,7 +6,7 @@ import time from django.conf import settings from django.db.models.signals import pre_save from django.utils.functional import curry -from django.db.models.loading import get_model +from django.apps import apps from auditlog.models import LogEntry @@ -65,9 +65,9 @@ class AuditlogMiddleware(object): """ try: app_label, model_name = settings.AUTH_USER_MODEL.split('.') - auth_user_model = get_model(app_label, model_name) + auth_user_model = apps.get_model(app_label, model_name) except ValueError: - auth_user_model = get_model('auth', 'user') + auth_user_model = apps.get_model('auth', 'user') if sender == LogEntry and isinstance(user, auth_user_model) and instance.actor is None: instance.actor = user if hasattr(threadlocal, 'auditlog'):