From a8bfb5007ed13b586367f7473d5e35eca3befa99 Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Thu, 6 Apr 2017 14:11:56 +0200 Subject: [PATCH] Fix TypeError on Python 3 when querystring is preserved in the admin. Fixes: #263 --- polymorphic/admin/parentadmin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polymorphic/admin/parentadmin.py b/polymorphic/admin/parentadmin.py index 744ac28..0169225 100644 --- a/polymorphic/admin/parentadmin.py +++ b/polymorphic/admin/parentadmin.py @@ -359,7 +359,9 @@ class PolymorphicParentModelAdmin(admin.ModelAdmin): extra_qs = '' if request.META['QUERY_STRING']: - extra_qs = '&' + request.META['QUERY_STRING'] + # QUERY_STRING is bytes in Python 3, using force_text() to decode it as string. + # See QueryDict how Django deals with that. + extra_qs = '&{0}'.format(force_text(request.META['QUERY_STRING'])) choices = self.get_child_type_choices(request, 'add') if len(choices) == 1: