from django.contrib.comments.forms import CommentForm
from recaptcha_comments.fields import RecaptchaField

class RecaptchaCommentForm(CommentForm):
    captcha = RecaptchaField()

    def clean_captcha(self):
        if not 'preview' in self.data:
            captcha_data = self.cleaned_data['captcha']
            return self.fields['captcha'].verify(captcha_data)

from django.contrib.comments.forms import CommentForm
from recaptcha_comments.fields import RecaptchaField

class RecaptchaCommentForm(CommentForm):
    captcha = RecaptchaField()

    def clean_captcha(self):
        if not 'preview' in self.data:
            captcha_data = self.cleaned_data['captcha']
            return self.fields['captcha'].verify(captcha_data)
        return self.cleaned_data['captcha']

Fix a flow issue (long standing bug)
Fix a flow issue (long standing bug)

  from django.contrib.comments.forms import CommentForm
  from recaptcha_comments.fields import RecaptchaField
  
  class RecaptchaCommentForm(CommentForm):
      captcha = RecaptchaField()
  
      def clean_captcha(self):
          if not 'preview' in self.data:
              captcha_data = self.cleaned_data['captcha']
              return self.fields['captcha'].verify(captcha_data)
+         return self.cleaned_data['captcha']
  
Fix a flow issue (long standing bug)
## Code Before:
from django.contrib.comments.forms import CommentForm
from recaptcha_comments.fields import RecaptchaField

class RecaptchaCommentForm(CommentForm):
    captcha = RecaptchaField()

    def clean_captcha(self):
        if not 'preview' in self.data:
            captcha_data = self.cleaned_data['captcha']
            return self.fields['captcha'].verify(captcha_data)

## Instruction:
Fix a flow issue (long standing bug)
## Code After:
from django.contrib.comments.forms import CommentForm
from recaptcha_comments.fields import RecaptchaField

class RecaptchaCommentForm(CommentForm):
    captcha = RecaptchaField()

    def clean_captcha(self):
        if not 'preview' in self.data:
            captcha_data = self.cleaned_data['captcha']
            return self.fields['captcha'].verify(captcha_data)
        return self.cleaned_data['captcha']
