diff --git a/docs/advanced_options.rst b/docs/advanced_options.rst index 4462fc2..0e1b0e6 100644 --- a/docs/advanced_options.rst +++ b/docs/advanced_options.rst @@ -272,3 +272,9 @@ Settings ``MODERATION_MODERATORS`` Tuple of moderators' email addresses to which notifications will be sent. + +Using with proxy classes +-------- + +- Register each proxy class individually. +- Register concrete class **also** but only after registering any proxy classes under this concrete class. \ No newline at end of file diff --git a/example_project/urls.py b/example_project/urls.py index 43e57be..f34156f 100644 --- a/example_project/urls.py +++ b/example_project/urls.py @@ -4,10 +4,10 @@ from django.contrib import admin from django.contrib.auth import views as auth_views -from moderation.helpers import auto_discover +from django.utils.module_loading import autodiscover_modules admin.autodiscover() -auto_discover() +autodiscover_modules("moderator") handler500 # Pyflakes diff --git a/moderation/admin.py b/moderation/admin.py index a8f183a..2087387 100644 --- a/moderation/admin.py +++ b/moderation/admin.py @@ -184,7 +184,7 @@ def change_view(self, request, object_id, extra_context=None): elif 'reject' in request.POST: moderated_object.reject(request.user, reason) - content_type = ContentType.objects.get_for_model(changed_obj.__class__) + content_type = ContentType.objects.get_for_model(changed_obj.__class__, for_concrete_model=False) try: object_admin_url = reverse( "admin:%s_%s_change" % (content_type.app_label, content_type.model), diff --git a/moderation/filterspecs.py b/moderation/filterspecs.py index 7fc4095..385a609 100644 --- a/moderation/filterspecs.py +++ b/moderation/filterspecs.py @@ -12,7 +12,7 @@ def _registered_content_types(): registered = list(moderation._registered_models.keys()) registered.sort(key=lambda obj: obj.__name__) for model in registered: - content_types.append(ContentType.objects.get_for_model(model)) + content_types.append(ContentType.objects.get_for_model(model, for_concrete_model=False)) return content_types diff --git a/moderation/managers.py b/moderation/managers.py index 077ec8a..b1d72ad 100644 --- a/moderation/managers.py +++ b/moderation/managers.py @@ -71,12 +71,12 @@ def get_for_instance(self, instance): try: moderated_object = self.get( object_pk=instance.pk, - content_type=ContentType.objects.get_for_model(instance.__class__), + content_type=ContentType.objects.get_for_model(instance.__class__, for_concrete_model=False), ) except self.model.MultipleObjectsReturned: # Get the most recent one moderated_object = self.filter( object_pk=instance.pk, - content_type=ContentType.objects.get_for_model(instance.__class__), + content_type=ContentType.objects.get_for_model(instance.__class__, for_concrete_model=False), ).order_by('-updated')[0] return moderated_object