From bae6f249a2949a43f2ea1362d1eace039da242c6 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 18 Aug 2020 21:30:23 +0200 Subject: [PATCH] Fix save & preview at creation --- articles/admin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/articles/admin.py b/articles/admin.py index 5f41326..e90a21d 100644 --- a/articles/admin.py +++ b/articles/admin.py @@ -75,6 +75,11 @@ class ArticleAdmin(admin.ModelAdmin): class Media: css = {"all": ("admin_articles.css",)} + def response_post_save_add(self, request, obj: Article): + if "_preview" in request.POST: + return redirect("article-detail", slug=obj.slug) + return super().response_post_save_add(request, obj) + def response_change(self, request, obj: Article): if "_preview" in request.POST: obj.save()