From 0df9fb8f9abdb0fbc1ba8b249ae9b71cc06af8e2 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 27 Feb 2006 18:52:54 +0000 Subject: [PATCH] Fixed #620 -- raw_id_admin and limit_choices_to now play well together (thanks to David Schein) git-svn-id: http://code.djangoproject.com/svn/django/trunk@2414 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../contrib/admin/media/js/admin/RelatedObjectLookups.js | 8 +++++++- django/contrib/admin/templates/widget/foreign.html | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/django/contrib/admin/media/js/admin/RelatedObjectLookups.js b/django/contrib/admin/media/js/admin/RelatedObjectLookups.js index b690bf6bee..35b949b30d 100644 --- a/django/contrib/admin/media/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/media/js/admin/RelatedObjectLookups.js @@ -3,7 +3,13 @@ function showRelatedObjectLookupPopup(triggeringLink) { var name = triggeringLink.id.replace(/^lookup_/, ''); - var win = window.open(triggeringLink.href + '?pop=1', name, 'height=500,width=740,resizable=yes,scrollbars=yes'); + var href + if (triggeringLink.href.search(/\?/) >= 0) { + href = triggeringLink.href + '&pop=1'; + } else { + href = triggeringLink.href + '?pop=1' + } + var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes'); win.focus(); return false; } diff --git a/django/contrib/admin/templates/widget/foreign.html b/django/contrib/admin/templates/widget/foreign.html index 1ac9b29844..582d65df7f 100644 --- a/django/contrib/admin/templates/widget/foreign.html +++ b/django/contrib/admin/templates/widget/foreign.html @@ -1,7 +1,11 @@ {% load admin_modify adminmedia %} {% output_all bound_field.form_fields %} {% if bound_field.raw_id_admin %} +{% if bound_field.field.rel.limit_choices_to %} + Lookup +{% else %} Lookup +{% endif %} {% else %} {% if bound_field.needs_add_label %} Add Another