﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26681	save_as=True and inlines in ModelAdmin raises ValidationError	Andreas Stocker	nobody	"{{{ModelAdmin}}} raises a {{{ValidationError}}} exception when trying to save after the first time trying to save with ""Save as new"" failed with form errors. The exception message is {{{[u""'' value must be an integer.""]}}}

**Steps to reproduce:**

1.) Register a ModelAdmin with inlines:
{{{#!python
class MyStackedInline(admin.StackedInline):
    model = MyInlineModel
    extra = 1

class MyAdmin(admin.ModelAdmin):
    inlines = [MyStackedInline, ]
    save_as = True

admin.site.register(MyModel, MyAdmin)
}}}

2.) Go to the admin panel, open an existing {{{MyModel}}} object and change the form contents in a way that causes form errors (e.g. keep an required field blank).
3.) Click on the ""Save as new"" button.
4.) The form now shows the validation errors. Fix them and click on the ""Save and add another"" button. Notice there is no ""Save as new"" button any more, though {{{save_as=True}}}.
5.) The admin panel now raises the {{{ValidationError}}} exception.


**Stacktrace:**
{{{#!python
File ""/my/app/venv/lib/python2.7/site-packages/django/core/handlers/base.py"" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/contrib/admin/options.py"" in wrapper
  618.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/utils/decorators.py"" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/views/decorators/cache.py"" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/contrib/admin/sites.py"" in inner
  233.             return view(request, *args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/contrib/admin/options.py"" in add_view
  1518.         return self.changeform_view(request, None, form_url, extra_context)
File ""/my/app/venv/lib/python2.7/site-packages/django/utils/decorators.py"" in _wrapper
  34.             return bound_func(*args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/utils/decorators.py"" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/utils/decorators.py"" in bound_func
  30.                 return func.__get__(self, type(self))(*args2, **kwargs2)
File ""/my/app/venv/lib/python2.7/site-packages/django/utils/decorators.py"" in inner
  145.                     return func(*args, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/contrib/admin/options.py"" in changeform_view
  1468.             if all_valid(formsets) and form_validated:
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/formsets.py"" in all_valid
  439.         if not formset.is_valid():
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/formsets.py"" in is_valid
  304.         self.errors
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/formsets.py"" in errors
  278.             self.full_clean()
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/formsets.py"" in full_clean
  326.             form = self.forms[i]
File ""/my/app/venv/lib/python2.7/site-packages/django/utils/functional.py"" in __get__
  59.         res = instance.__dict__[self.name] = self.func(instance)
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/formsets.py"" in forms
  142.         forms = [self._construct_form(i) for i in range(self.total_form_count())]
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/models.py"" in _construct_form
  868.         form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
File ""/my/app/venv/lib/python2.7/site-packages/django/forms/models.py"" in _construct_form
  586.             pk = to_python(pk)
File ""/my/app/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py"" in to_python
  969.                 params={'value': value},

Exception Type: ValidationError at /admin/myapp/mymodel/add/
Exception Value: [u""'' value must be an integer.""]
}}}"	Bug	closed	contrib.admin	1.8	Normal	duplicate			Unreviewed	0	0	0	0	0	0
