diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 8a7483c..67b09d3 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
1181 | 1181 | 'preserved_filters': self.get_preserved_filters(request), |
1182 | 1182 | } |
1183 | 1183 | context.update(extra_context or {}) |
| 1184 | # Send back to Change form if we get a validation error preventing Save as New |
| 1185 | if request.method == 'POST' and not form_validated and "_saveasnew" in request.POST: |
| 1186 | # Hide Save and Save Continue buttons since Save as New was previously chosen and the others are broken. |
| 1187 | context['show_save'] = False |
| 1188 | context['show_save_and_continue'] = False |
| 1189 | return self.render_change_form(request, context, form_url=form_url, change=True) |
1184 | 1190 | return self.render_change_form(request, context, form_url=form_url, add=True) |
1185 | 1191 | |
1186 | 1192 | @csrf_protect_m |
diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py
index 98ac1a6..8f7d6fb 100644
a
|
b
|
def submit_row(context):
|
28 | 28 | change = context['change'] |
29 | 29 | is_popup = context['is_popup'] |
30 | 30 | save_as = context['save_as'] |
| 31 | show_save = context.get('show_save', True) |
| 32 | show_save_and_continue = context.get('show_save_and_continue', True) |
31 | 33 | ctx = { |
32 | 34 | 'opts': opts, |
33 | 35 | 'show_delete_link': (not is_popup and context['has_delete_permission'] |
… |
… |
def submit_row(context):
|
35 | 37 | 'show_save_as_new': not is_popup and change and save_as, |
36 | 38 | 'show_save_and_add_another': context['has_add_permission'] and |
37 | 39 | not is_popup and (not save_as or context['add']), |
38 | | 'show_save_and_continue': not is_popup and context['has_change_permission'], |
| 40 | 'show_save_and_continue': not is_popup and context['has_change_permission'] and show_save_and_continue, |
39 | 41 | 'is_popup': is_popup, |
40 | | 'show_save': True, |
| 42 | 'show_save': show_save, |
41 | 43 | 'preserved_filters': context.get('preserved_filters'), |
42 | 44 | } |
43 | 45 | if context.get('original') is not None: |