﻿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
25587	"Django fails, when trying to save object ""as new"" with inlines objects and form validation errors."	user0007	nobody	"Let's assume that I have one existing object in Django Admin with some related objects (inlines). When I try to create a clone (by clicking on ""Save as new""), but there are some validation errors, Django will fail, after clicking ""Save and continue editing"".

Everything works without inlines objects.

Error:

{{{
django.db.models.fields in get_prep_value
ValueError: invalid literal for int() with base 10: ''
}}}

Stacktrace (most recent call last):

{{{
  File ""django/core/handlers/base.py"", line 113, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File ""django/contrib/admin/options.py"", line 406, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File ""django/utils/decorators.py"", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ""django/views/decorators/cache.py"", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File ""django/contrib/admin/sites.py"", line 202, in inner
    return view(request, *args, **kwargs)
  File ""django/utils/decorators.py"", line 25, in _wrapper
    return bound_func(*args, **kwargs)
  File ""django/utils/decorators.py"", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ""django/utils/decorators.py"", line 21, in bound_func
    return func(self, *args2, **kwargs2)
  File ""django/db/transaction.py"", line 223, in inner
    return func(*args, **kwargs)
  File ""django/contrib/admin/options.py"", line 1038, in add_view
    prefix=prefix, queryset=inline.queryset(request))
  File ""www/forms.py"", line 566, in __init__
    super(UczestnikAdminInlineFormset, self).__init__(*args, **kwargs)
  File ""django/forms/models.py"", line 720, in __init__
    queryset=qs, **kwargs)
  File ""django/forms/models.py"", line 441, in __init__
    super(BaseModelFormSet, self).__init__(**defaults)
  File ""django/forms/formsets.py"", line 56, in __init__
    self._construct_forms()
  File ""django/forms/formsets.py"", line 124, in _construct_forms
    self.forms.append(self._construct_form(i))
  File ""django/forms/models.py"", line 729, in _construct_form
    form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
  File ""django/forms/models.py"", line 463, in _construct_form
    connection=connections[self.get_queryset().db])
  File ""django/db/models/fields/__init__.py"", line 340, in get_db_prep_lookup
    value = self.get_prep_lookup(lookup_type, value)
  File ""django/db/models/fields/__init__.py"", line 322, in get_prep_lookup
    return self.get_prep_value(value)
  File ""django/db/models/fields/__init__.py"", line 555, in get_prep_value
    return int(value)
}}}


"	Bug	closed	contrib.admin	1.8	Normal	duplicate			Unreviewed	0	0	0	0	0	0
