From 64cf4b95a67e6f9911ab67e971c7d57fced9522b Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 18 Aug 2006 21:39:29 +0000 Subject: [PATCH] Fixed bug in [3553] -- Changed admin JavaScript quoting for related-object popup window not to use repr(), because that produces values such as 123L for longints. Refs #2500 git-svn-id: http://code.djangoproject.com/svn/django/trunk@3613 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/views/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 2f1e9722e1..7c942ca5b8 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -263,7 +263,9 @@ def add_stage(request, app_label, model_name, show_delete=False, form_url='', po post_url_continue += "?_popup=1" return HttpResponseRedirect(post_url_continue % pk_value) if request.POST.has_key("_popup"): - return HttpResponse('' % \ + if type(pk_value) is str: # Quote if string, so JavaScript doesn't think it's a variable. + pk_value = '"%s"' % pk_value.replace('"', '\\"') + return HttpResponse('' % \ (pk_value, str(new_object).replace('"', '\\"'))) elif request.POST.has_key("_addanother"): request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name)) @@ -720,7 +722,7 @@ class ChangeList(object): return "%s__search" % field_name[1:] else: return "%s__icontains" % field_name - + if self.lookup_opts.admin.search_fields and self.query: for bit in self.query.split(): or_queries = [models.Q(**{construct_search(field_name): bit}) for field_name in self.lookup_opts.admin.search_fields]