forum: enhance performances on toggle_favorite

This commit is contained in:
Antoine Bartuccio 2019-09-15 16:00:50 +02:00
parent 3eb8292d15
commit 321e5e3ff5
Signed by: klmp200
GPG Key ID: E7245548C53F904B

View File

@ -280,7 +280,7 @@ class ForumTopicSubscribeView(CanViewMixin, SingleObjectMixin, RedirectView):
def get(self, request, *args, **kwargs):
self.object = self.get_object()
if request.user in self.object.subscribed_users.all():
if self.object.subscribed_users.filter(id=request.user.id).exists():
self.object.subscribed_users.remove(request.user)
else:
self.object.subscribed_users.add(request.user)