def clean_book(self, *args, **kwargs):
    '\n        This method checks if a user has already reviewed\n        the selected book. As per django docs exists() is\n        an efficient way of checking this.\n        '
    book = self.cleaned_data.get('book')
    if Review.objects.filter(book=book, author=self.user).exists():
        raise forms.ValidationError('Book already reviewed by user {}'.format(self.user))
    else:
        return book
This method checks if a user has already reviewed
the selected book. As per django docs exists() is
an efficient way of checking this.
def clean_book(self, *args, **kwargs):
    '\n        This method checks if a user has already reviewed\n        the selected book. As per django docs exists() is\n        an efficient way of checking this.\n        '
    book = self.cleaned_data.get('book')
    if Review.objects.filter(book=book, author=self.user).exists():
        raise forms.ValidationError('Book already reviewed by user {}'.format(self.user))
    else:
        return book