--
Ticket URL: <https://code.djangoproject.com/ticket/17417>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_docs: => 0
Comment:
Duplicate of #13223. See also #5681.
--
Ticket URL: <https://code.djangoproject.com/ticket/17417#comment:1>
* status: closed => reopened
* resolution: duplicate =>
--
Ticket URL: <https://code.djangoproject.com/ticket/17417#comment:2>
* status: reopened => closed
* resolution: => worksforme
Comment:
(sorry, anonymous user above was me)
Wait, the OP doesn't mention inlines so this isn't a duplicate of #13223.
But I can't reproduce the reported error with this simple model
{{{
class Article(models.Model):
title = models.CharField(max_length=30)
slug = models.CharField(max_length=200, unique=True)
def __unicode__(self):
return self.title
}}}
and ModelAdmin
{{{
class ArticleAdmin(admin.ModelAdmin):
save_as = True
admin.site.register(Article, ArticleAdmin)
}}}
(tested this with 1.3 and trunk)
--
Ticket URL: <https://code.djangoproject.com/ticket/17417#comment:3>
* status: closed => reopened
* needs_better_patch: 0 => 1
* version: 1.3 => master
* resolution: worksforme =>
* stage: Unreviewed => Accepted
Comment:
This bug is valid, and I have a proof for that :) (see attached testcase).
The form is not showing the "save as new" button after a form validation
occured. The reason is pretty simple:
The "save as new" button is only shown on "change_view" pages (which makes
sense), see
https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_modify.py#L32
…
… however here …
https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1025
… is the "add_view" called when the object is saved, using the "save as
new" button.
--
Ticket URL: <https://code.djangoproject.com/ticket/17417#comment:4>
* cc: hirokiky@… (added)
Comment:
I added a patch to fix this bug.
It changes to call add_view when the form is valid and "_saveasnew" in
request.POST.
The form is not valid, it operates as same the normal "save" behavior.
The gregmuellegger's test patch can't be used as it is.
What do you say about this behavior?
--
Ticket URL: <https://code.djangoproject.com/ticket/17417#comment:6>
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #23387 which has been fixed in master (1.9) by only showing
the "Save as new" button if it's selected and there are validation errors.
--
Ticket URL: <https://code.djangoproject.com/ticket/17417#comment:7>