diff --git a/bitpoll/poll/models.py b/bitpoll/poll/models.py index 03241970..4fa99f58 100644 --- a/bitpoll/poll/models.py +++ b/bitpoll/poll/models.py @@ -88,7 +88,7 @@ def can_vote(self, user: AbstractUser, request: Optional[HttpRequest] = None, is if request: messages.error(request, _("Login required to vote.")) return False - elif self.require_invitation and (not user.is_authenticated or user not in self.invitation_set.all().values('user')): + elif self.require_invitation and (not user.is_authenticated or not self.invitation_set.filter(user=user).exists()): if request: messages.error(request, _("You are not allowed to vote in this poll. You have to be invited")) return False