Show action form errors using message_user

Not very neat, but way better than nothing when there are errors
(previously the error was invisible and the action simply seemed to have
completed).
This commit is contained in:
Gunnlaugur Þór Briem 2014-02-12 00:04:13 +00:00
parent 8c8e478a31
commit 423bb90c71

View file

@ -87,6 +87,10 @@ def edit_permissions(modeladmin, request, queryset):
if all_valid(formsets):
for formset in formsets:
formset.save()
else:
modeladmin.message_user(request, '; '.join(
err.as_text() for formset in formsets for err in formset.errors
))
# redirect to full request path to make sure we keep filter
return HttpResponseRedirect(request.get_full_path())