diff --git a/django/views/admin/main.py b/django/views/admin/main.py
index a6109a46cd..9283230b26 100644
--- a/django/views/admin/main.py
+++ b/django/views/admin/main.py
@@ -523,7 +523,7 @@ def _get_submit_row_template(opts, app_label, add, change, show_delete, ordered_
if not opts.admin.save_as or add:
t.append('{%% if not is_popup %%}{%% endif %%}' % \
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
- t.append('' % \
+ t.append('{%% if not is_popup %%}{%% endif %%}' % \
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
t.append('' % \
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))