catch integrityerrors in editor
import typing
from contextlib import suppress
+from sqlite3 import IntegrityError
from django.contrib import messages
from django.contrib.auth.views import redirect_to_login
@@ -289,8 +290,11 @@ def edit(request, pk=None, model=None, level=None, space=None, on_top_of=None, e
with request.changeset.lock_to_edit(request) as changeset:
if changeset.can_edit(request):
+ try:
obj.save()
-
+ except IntegrityError:
+ messages.error(request, _('Duplicate entry.'))
+ else:
if form.redirect_slugs is not None:
for slug in form.add_redirect_slugs:
obj.redirects.create(slug=slug)
