In Django Admin, saving an Object always goes back to it's List of Objects. Now i want to go to the List of Invoice-Objects upon saving a Payment-Object.
I tried several things:
In admin.py:
@receiver(post_save, sender=Payment)
def custom_redirect(sender, instance, **kwargs):
return HttpResponseRedirect('/admin/sales/invoice')
OR
class PaymentAdmin(VersionAdmin, admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
return HttpResponseRedirect('/admin/sales/invoice')
Instead of HttpResponseRedirect i tried using redirect() , but also with no effect. On inserting wrong code into post_save i get an error message - so it does get triggered, but the redirect does not happen.
Any hints would be very apreciated - as i'm stuck for days on this "simple" problem.
Thanks