Django admin "save and view on site" button
Besides adding button in change_form template, you would want to override response_change
method of ModelAdmin (and response_add
).
Something like this should work:
def response_change(self, request, obj):
res = super(MyModelAdmin, self).response_change(request, obj)
if "_preview" in request.POST:
return HttpResponseRedirect('preview-url-here')
else:
return res