I've some custom views in django-admin linked to my change_form. All works well, but now I'd want to raise a ValidationError from my custom views and consequently get the flash in django-admin that prints the msg of ValidationError, that is the same that occurs if I raise it in model.clean().
an example of custom view that I use:
@site.admin_view
def send_transaction_mail(request, obj_id, typ):
order = Order.objects.get(id=obj_id)
if typ == 'SHIPMENT':
send_order_confirm(order)
else:
raise Exception("Something goes wrong sending transaction mail")
return HttpResponseRedirect(request.META['HTTP_REFERER'])
is there a way? Thank you