Fix save & preview at creation

This commit is contained in:
Gabriel Augendre 2020-08-18 21:30:23 +02:00
parent f2a3f3efeb
commit bae6f249a2

View file

@ -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()