diff --git a/client/html/comment.tpl b/client/html/comment.tpl
index 6bea7045..df7b3664 100644
--- a/client/html/comment.tpl
+++ b/client/html/comment.tpl
@@ -26,7 +26,7 @@
%>'><%
%><% } %><%
- %><%- ctx.user ? ctx.user.name : 'Deleted user' %><%
+ %><%- ctx.user ? ctx.user.name : 'Anonymous' %><%
%><% if (ctx.user && ctx.user.name && ctx.canViewUsers) { %><%
%><%
diff --git a/server/szurubooru/api/comment_api.py b/server/szurubooru/api/comment_api.py
index d60d23ed..0dbc93de 100644
--- a/server/szurubooru/api/comment_api.py
+++ b/server/szurubooru/api/comment_api.py
@@ -48,7 +48,7 @@ def create_comment(
text = ctx.get_param_as_string("text")
post_id = ctx.get_param_as_int("postId")
post = posts.get_post_by_id(post_id)
- comment = comments.create_comment(ctx.user, post, text)
+ comment = comments.create_comment(ctx.user if ctx.user.name else None, post, text)
ctx.session.add(comment)
ctx.session.commit()
return _serialize(ctx, comment)
diff --git a/server/szurubooru/model/comment.py b/server/szurubooru/model/comment.py
index e64961e6..d35c5af1 100644
--- a/server/szurubooru/model/comment.py
+++ b/server/szurubooru/model/comment.py
@@ -46,7 +46,7 @@ class Comment(Base):
user_id = sa.Column(
"user_id",
sa.Integer,
- sa.ForeignKey("user.id"),
+ sa.ForeignKey("user.id", ondelete="SET NULL"),
nullable=True,
index=True,
)