Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Object IDs with special characters #66
object_id gets quoted by django admin. You need to unquote it, to get the result.
Here is a patch.
diff --git a/src/reversion/models.py b/src/reversion/models.py index f412887..dc0be32 100644 --- a/src/reversion/models.py +++ b/src/reversion/models.py @@ -6,6 +6,7 @@ from django.contrib.contenttypes.models import ContentType from django.core import serializers from django.db import models, IntegrityError from django.db.models import Count +from django.contrib.admin.util import unquote import reversion @@ -83,7 +84,7 @@ class VersionManager(models.Manager): def get_for_object_reference(self, model, object_id): """Returns all versions for the given object reference.""" content_type = ContentType.objects.get_for_model(model) - object_id = unicode(object_id) + object_id = unquote(unicode(object_id)) versions = self.filter(content_type=content_type, object_id=object_id) versions = versions.order_by("pk") return versions @@ -131,7 +132,7 @@ class VersionManager(models.Manager): select_related = tuple(select_related) + ("revision",) # Fetch the version. content_type = ContentType.objects.get_for_model(model_class) - object_id = unicode(object_id) + object_id = unquote(unicode(object_id)) versions = self.filter(content_type=content_type, object_id=object_id) versions = versions.order_by("-pk") if select_related:
I have updated the patch. The strange thing is this: django itself does not use its own quote/unquote every time. If you create a new object with a primary key with an underscore, the underscore is not quoted to _5F. But if you go back