diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 942385e1c6..e9f4a43185 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -40,6 +40,8 @@ from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.utils.encoding import force_text
+IS_POPUP_VAR = '_popup'
+
HORIZONTAL, VERTICAL = 1, 2
# returns the
class for a given radio_admin field
get_ul_class = lambda x: 'radiolist%s' % (' inline' if x == HORIZONTAL else '')
@@ -660,8 +662,8 @@ class ModelAdmin(BaseModelAdmin):
"""
# If self.actions is explicitly set to None that means that we don't
# want *any* actions enabled on this page.
- from django.contrib.admin.views.main import IS_POPUP_VAR
- if self.actions is None or IS_POPUP_VAR in request.GET:
+ from django.contrib.admin.views.main import _is_changelist_popup
+ if self.actions is None or _is_changelist_popup(request):
return SortedDict()
actions = []
@@ -908,7 +910,7 @@ class ModelAdmin(BaseModelAdmin):
msg_dict = {'name': force_text(opts.verbose_name), 'obj': force_text(obj)}
# Here, we distinguish between different save types by checking for
# the presence of keys in request.POST.
- if "_popup" in request.POST:
+ if IS_POPUP_VAR in request.POST:
return HttpResponse(
''
'' % \
@@ -1158,7 +1160,7 @@ class ModelAdmin(BaseModelAdmin):
context = {
'title': _('Add %s') % force_text(opts.verbose_name),
'adminform': adminForm,
- 'is_popup': "_popup" in request.REQUEST,
+ 'is_popup': IS_POPUP_VAR in request.REQUEST,
'media': media,
'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets),
@@ -1251,7 +1253,7 @@ class ModelAdmin(BaseModelAdmin):
'adminform': adminForm,
'object_id': object_id,
'original': obj,
- 'is_popup': "_popup" in request.REQUEST,
+ 'is_popup': IS_POPUP_VAR in request.REQUEST,
'media': media,
'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets),
diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
index ce54fa5083..6d1748663e 100644
--- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
+++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
@@ -32,9 +32,9 @@ function showRelatedObjectLookupPopup(triggeringLink) {
name = id_to_windowname(name);
var href;
if (triggeringLink.href.search(/\?/) >= 0) {
- href = triggeringLink.href + '&pop=1';
+ href = triggeringLink.href + '&_popup=1';
} else {
- href = triggeringLink.href + '?pop=1';
+ href = triggeringLink.href + '?_popup=1';
}
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
win.focus();
diff --git a/django/contrib/admin/templates/admin/search_form.html b/django/contrib/admin/templates/admin/search_form.html
index f5a9e7b8b9..c9b626d18f 100644
--- a/django/contrib/admin/templates/admin/search_form.html
+++ b/django/contrib/admin/templates/admin/search_form.html
@@ -6,7 +6,7 @@
{% if show_result_count %}
- {% blocktrans count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktrans %} ({% blocktrans with full_result_count=cl.full_result_count %}{{ full_result_count }} total{% endblocktrans %})
+ {% blocktrans count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktrans %} ({% blocktrans with full_result_count=cl.full_result_count %}{{ full_result_count }} total{% endblocktrans %})
{% endif %}
{% for pair in cl.params.items %}
{% ifnotequal pair.0 search_var %}{% endifnotequal %}
diff --git a/django/contrib/admin/templatetags/admin_urls.py b/django/contrib/admin/templatetags/admin_urls.py
index bb1b16883d..19da87d61f 100644
--- a/django/contrib/admin/templatetags/admin_urls.py
+++ b/django/contrib/admin/templatetags/admin_urls.py
@@ -1,5 +1,3 @@
-from django.utils.http import urlencode
-
try:
from urllib.parse import parse_qsl, urlparse, urlunparse
except ImportError:
@@ -8,6 +6,7 @@ except ImportError:
from django import template
from django.contrib.admin.util import quote
from django.core.urlresolvers import resolve, Resolver404
+from django.utils.http import urlencode
register = template.Library()
@@ -47,7 +46,8 @@ def add_preserved_filters(context, url, popup=False):
merged_qs.update(preserved_filters)
if popup:
- merged_qs['_popup'] = 1
+ from django.contrib.admin.options import IS_POPUP_VAR
+ merged_qs[IS_POPUP_VAR] = 1
merged_qs.update(parsed_qs)
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index f676706a89..56462dece8 100644
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -15,7 +15,7 @@ from django.utils.http import urlencode
from django.contrib.admin import FieldListFilter
from django.contrib.admin.exceptions import DisallowedModelAdminLookup
-from django.contrib.admin.options import IncorrectLookupParameters
+from django.contrib.admin.options import IncorrectLookupParameters, IS_POPUP_VAR
from django.contrib.admin.util import (quote, get_fields_from_path,
lookup_needs_distinct, prepare_lookup_value)
@@ -26,7 +26,6 @@ ORDER_TYPE_VAR = 'ot'
PAGE_VAR = 'p'
SEARCH_VAR = 'q'
TO_FIELD_VAR = 't'
-IS_POPUP_VAR = 'pop'
ERROR_FLAG = 'e'
IGNORED_PARAMS = (
@@ -36,6 +35,29 @@ IGNORED_PARAMS = (
EMPTY_CHANGELIST_VALUE = ugettext_lazy('(None)')
+def _is_changelist_popup(request):
+ """
+ Returns True if the popup GET parameter is set.
+
+ This function is introduced to facilitate deprecating the legacy
+ value for IS_POPUP_VAR and should be removed at the end of the
+ deprecation cycle.
+ """
+
+ if IS_POPUP_VAR in request.GET:
+ return True
+
+ IS_LEGACY_POPUP_VAR = 'pop'
+ if IS_LEGACY_POPUP_VAR in request.GET:
+ warnings.warn(
+ "The `%s` GET parameter has been renamed to `%s`." %
+ (IS_LEGACY_POPUP_VAR, IS_POPUP_VAR),
+ PendingDeprecationWarning, 2)
+ return True
+
+ return False
+
+
class RenameChangeListMethods(RenameMethodsBase):
renamed_methods = (
('get_query_set', 'get_queryset', PendingDeprecationWarning),
@@ -67,7 +89,7 @@ class ChangeList(six.with_metaclass(RenameChangeListMethods)):
except ValueError:
self.page_num = 0
self.show_all = ALL_VAR in request.GET
- self.is_popup = IS_POPUP_VAR in request.GET
+ self.is_popup = _is_changelist_popup(request)
self.to_field = request.GET.get(TO_FIELD_VAR)
self.params = dict(request.GET.items())
if PAGE_VAR in self.params:
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
index 409078fa02..5a1db68613 100644
--- a/django/contrib/auth/admin.py
+++ b/django/contrib/auth/admin.py
@@ -1,6 +1,7 @@
from django.db import transaction
from django.conf import settings
from django.contrib import admin
+from django.contrib.admin.options import IS_POPUP_VAR
from django.contrib.auth.forms import (UserCreationForm, UserChangeForm,
AdminPasswordChangeForm)
from django.contrib.auth.models import User, Group
@@ -143,7 +144,7 @@ class UserAdmin(admin.ModelAdmin):
'adminForm': adminForm,
'form_url': form_url,
'form': form,
- 'is_popup': '_popup' in request.REQUEST,
+ 'is_popup': IS_POPUP_VAR in request.REQUEST,
'add': True,
'change': False,
'has_delete_permission': False,
@@ -170,7 +171,7 @@ class UserAdmin(admin.ModelAdmin):
# button except in two scenarios:
# * The user has pressed the 'Save and add another' button
# * We are adding a user in a popup
- if '_addanother' not in request.POST and '_popup' not in request.POST:
+ if '_addanother' not in request.POST and IS_POPUP_VAR not in request.POST:
request.POST['_continue'] = 1
return super(UserAdmin, self).response_add(request, obj,
post_url_continue)
diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
index bd6255eae6..16e0b94a9d 100644
--- a/docs/releases/1.6.txt
+++ b/docs/releases/1.6.txt
@@ -725,6 +725,12 @@ Miscellaneous
returned ``False`` for blank passwords. This has been corrected in this
release: blank passwords are now valid.
+* The admin :attr:`~django.contrib.admin.ModelAdmin.changelist_view` previously
+ accepted a ``pop`` GET parameter to signify it was to be displayed in a popup.
+ This parameter has been renamed to ``_popup`` to be consistent with the rest
+ of the admin views. You should update your custom templates if they use the
+ previous parameter name.
+
Features deprecated in 1.6
==========================