From 67dd5c0a0dd33537c1deb946dbae0c8e98fbecb2 Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Mon, 10 Jul 2017 10:57:07 +0200 Subject: [PATCH] Reverted int/long change, as Django's BigIntegerField can produce longs on Python 2 --- polymorphic/admin/parentadmin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/polymorphic/admin/parentadmin.py b/polymorphic/admin/parentadmin.py index d156ca2..da7dffc 100644 --- a/polymorphic/admin/parentadmin.py +++ b/polymorphic/admin/parentadmin.py @@ -1,6 +1,7 @@ """ The parent admin displays the list view of the base model. """ +import sys import warnings import django @@ -21,6 +22,10 @@ from django.utils.translation import ugettext_lazy as _ from .forms import PolymorphicModelChoiceForm +if sys.version_info[0] >= 3: + long = int + + class RegistrationClosed(RuntimeError): "The admin model can't be registered anymore at this point." @@ -315,9 +320,9 @@ class PolymorphicParentModelAdmin(admin.ModelAdmin): try: pos = path.find('/') if pos == -1: - object_id = int(path) + object_id = long(path) else: - object_id = int(path[0:pos]) + object_id = long(path[0:pos]) except ValueError: raise Http404("No ct_id parameter, unable to find admin subclass for path '{0}'.".format(path))