Return 404 for non-existent users

This commit is contained in:
Quantum 2024-09-15 22:09:02 -04:00 committed by Guanzhong Chen
parent 886fd42600
commit e381e1f9b8

View File

@ -81,7 +81,7 @@ class UserPage(TitleMixin, UserMixin, DetailView):
return super(UserPage, self).dispatch(request, *args, **kwargs) return super(UserPage, self).dispatch(request, *args, **kwargs)
except Http404: except Http404:
return generic_message(request, _('No such user'), _('No user handle "%s".') % return generic_message(request, _('No such user'), _('No user handle "%s".') %
self.kwargs.get(self.slug_url_kwarg, None)) self.kwargs.get(self.slug_url_kwarg, None), status=404)
def get_title(self): def get_title(self):
return (_('My account') if self.request.user == self.object.user else return (_('My account') if self.request.user == self.object.user else