Giter Club home page Giter Club logo

django-recaptcha2's Introduction

Django reCaptcha v2 Build Status


This integration app implements a recaptcha field for Google reCaptcha v2 with explicit rendering and multiple recaptcha support. The invisible version of the reCAPTCHA with the automatic render mode is now supported, please read the related documentation below.

Are you looking for the Google reCaptcha v3? Take a look to the dedicated repository https://github.com/kbytesys/django-recaptcha3


How to install

Install the required package from pip (or take the source and install it by yourself):

pip install django-recaptcha2

Then add django-recaptcha2 to your installed apps:

INSTALLED_APPS = (
    ...
    'snowpenguin.django.recaptcha2',
    ...
)

And add your reCaptcha private and public key to your django settings.py:

RECAPTCHA_PRIVATE_KEY = 'your private key'
RECAPTCHA_PUBLIC_KEY = 'your public key'
# If you require reCaptcha to be loaded from somewhere other than https://google.com
# (e.g. to bypass firewall restrictions), you can specify what proxy to use.
# RECAPTCHA_PROXY_HOST = 'https://recaptcha.net'

If you have to create the apikey for the domains managed by your django project, you can visit this website.

"I'm not a robot" Usage

Form and Widget

You can simply create a reCaptcha enabled form with the field provided by this app:

from snowpenguin.django.recaptcha2.fields import ReCaptchaField
from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget

class ExampleForm(forms.Form):
    [...]
    captcha = ReCaptchaField(widget=ReCaptchaWidget())
    [...]

You can set the private key on the "private_key" argument of the field contructor and you can pass some parameters into the widget contructor:

class ReCaptchaWidget(Widget):
    def __init__(self, explicit=False, container_id=None, theme=None, type=None, size=None, tabindex=None,
                 callback=None, expired_callback=None, attrs={}, *args, **kwargs):

If you set the explicit boolean to true, you will render this field with explicit render support. This is useful if you want to use multiple forms with reCaptcha in one page. Take a look to template and samples sections for more info.

You can personalize reCaptcha theme, type, size, tabindex, callback and expired_callback parameters. Look the reCaptcha documentation if you want to change those values. Warning: the app doesn't validate the incoming parameter values.

Recaptcha "container id"

Now the default container id for the recaptcha is:

  • recaptcha-{$fieldname} for the automatic rendering
  • recaptcha-{$fieldname}-{%fiverandomdigits} for the explicit rendering

This avoids name collisions when you use multiple instances of the recaptcha in different forms, but in the same page and with the same field name.

Note: you can always override the container id with the "container_id" argument in the widget constructor, but take care: nobody will check if the id you provide is already used.

Templating

You can use some template tags to simplify the reCaptcha adoption:

  • recaptcha_init: add the script tag for reCaptcha api. You have to put this tag somewhere in your "head" element
  • recaptcha_explicit_init: add the script tag for the reCaptcha api with explicit render support. You have to put this tag somewhere above the end of your "body" element. If you use this tag, you don't have to use "recaptcha_init".
  • recaptcha_explicit_support: this tag add the callback function used by reCaptcha for explicit rendering. This tag also add some funcitions and javascript vars used by the ReCaptchaWidget when it is initialized with explicit=True. You have to put this tag somewhere in your "head" element.
  • recaptcha_key: if you want to use reCaptcha manually in your template, you will need the sitekey (a.k.a. public api key). This tag returns a string with the configured public key.

You can use the form as usual.

Force widget language

You can disable the language auto-detection in the recaptha2 init tag:

{% load recaptcha2 %}
<html>
  <head>
      {% recaptcha_init 'es' %}
  </head>

or

    </form>
    {% recaptcha_explicit_init 'es'%}
  </body>
</html>

For language codes take a look to this page.

Samples

Simple render example

Just create a form with the reCaptcha field and follow this template example:

{% load recaptcha2 %}
<html>
  <head>
      {% recaptcha_init %}
  </head>
  <body>
    <form action="?" method="POST">
      {% csrf_token %}
      {{ form }}
      <input type="submit" value="Submit">
    </form>
  </body>
</html>

Explicit render example

Create a form with explicit=True and write your template like this:

{% load recaptcha2 %}
<html>
  <head>
    {% recaptcha_explicit_support %}
  </head>
  <body>
    <form action="?" method="POST">
      {% csrf_token %}
      {{ form }}
      <input type="submit" value="Submit">
    </form>
    {% recaptcha_explicit_init %}
  </body>
</html>

Multiple render example

You can render multiple reCaptcha using only forms with explicit=True:

{% load recaptcha2 %}
<html>
  <head>
      {% recaptcha_explicit_support %}
  </head>
  <body>
    <form action="{% url 'form1_post' %}" method="POST">
      {% csrf_token %}
      {{ form1 }}
      <input type="submit" value="Submit">
    </form>
    <form action="{% url 'form2_post' %}" method="POST">
      {% csrf_token %}
      {{ form2 }}
      <input type="submit" value="Submit">
    </form>
    {% recaptcha_explicit_init %}
  </body>
</html>

Mix manual render with app support

You can use the app explicit render support also is you implement reCaptcha in one of your form in the template:

{% load recaptcha2 %}
<html>
    <head>
        {% recaptcha_explicit_support %}
    </head>
    <body>
        [...]
        <div id='recaptcha'></div>
        <script>
            django_recaptcha_callbacks.push(function() {
                grecaptcha.render('recaptcha', {
                    'theme': 'dark',
                    'sitekey': '{% recaptcha_key %}'
                })
            });
        </script>
        [...]
        {% recaptcha_explicit_init %}
    </body>
</html>

"Invisible" Usage

The implementation and the usage of this kind of binding is simpler and you don't need to use the explicit rendering to add multiple instances of the reCAPTCHA.

Form and Widget

You can simply create a reCaptcha enabled form with the field provided by this app:

from snowpenguin.django.recaptcha2.fields import ReCaptchaField
from snowpenguin.django.recaptcha2.widgets import ReCaptchaHiddenInput

class ExampleForm(forms.Form):
    [...]
    captcha = ReCaptchaField(widget=ReCaptchaHiddenInput())
    [...]

You can set the private key on the "private_key" argument of the field contructor.

Templating

You just need to add the "recaptcha_init" tag on the head of your page and to place the invisible reCAPTCHA submit button inside your form:

<form id='myform1' action="?" method="POST">
      {% csrf_token %}
      {{ form }}
      {% recaptcha_invisible_button submit_label='Submit' %}
</form>

You can customize the button with the parameters included in its definition:

def recaptcha_invisible_button(public_key=None, submit_label=None, extra_css_classes=None,
                               form_id=None, custom_callback=None):

You can override the reCAPTCHA public key, change the label of the button, apply extra css classes, force the button to submit a form identified by id or provide the name of a custom callback. Please check the samples to understand how it works.

Samples

Simple usage

{% load recaptcha2 %}
<html>
  <head>
      {% recaptcha_init %}
  </head>
  <body>
    <form action="?" method="POST">
      {% csrf_token %}
      {{ form }}
      {% recaptcha_invisible_button submit_label='Submit' %}
    </form>
  </body>
</html>

Note: The button will looking for the first "form" element using che "Element.closest" function. IE doesn't support it, so please use a polyfill (for example https://polyfill.io). If you don't want to add extra javascript libraries, please use the form id or a custom callback.

Form id

{% load recaptcha2 %}
<html>
  <head>
      {% recaptcha_init %}
  </head>
  <body>
    <form id='myform' action="?" method="POST">
      {% csrf_token %}
      {{ form }}
      {% recaptcha_invisible_button submit_label='Submit' form_id='myform' %}
    </form>
  </body>
</html>

Custom callback

{% load recaptcha2 %}
<html>
  <head>
      {% recaptcha_init %}
  </head>
  <body>
    <form id='myform' action="?" method="POST">
      {% csrf_token %}
      {{ form }}
      {% recaptcha_invisible_button submit_label='Submit' custom_callback='mycallback' %}
      <script>
          function mycallback(token) {
              someFunction();
              document.getElementById("myform").submit();
          }
      </script>
    </form>
  </body>
</html>

TODO/ISSUES

  • Only the automatic binding is supported, but you can add the dummy widget inside your form and the required javascript code in your template in order to use the programmatically bind and invoke.

  • You can only configure one reCAPTCHA key in the configuration. This isn't a real problem because if you want to use the invisible reCAPTCHA you don't need to use the "old one" anymore. If you need to use both implementations you can still set the public and private keys in the fields, tags and widgets constructors.

  • ReCaptchaHiddenInput could be the starting point for the creation of some "I'm not a robot" reCAPTCHA template tags to use in place of the ReCaptchaWidget (maybe in a future release)

Testing

Test unit support

You can't simulate api calls in your test, but you can disable the recaptcha field and let your test works.

Just set the RECAPTCHA_DISABLE env variable in your test:

os.environ['RECAPTCHA_DISABLE'] = 'True'

Warning: you can use any word in place of "True", the clean function will check only if the variable exists.

Test unit with recaptcha2 disabled

import os
import unittest

from yourpackage.forms import MyForm

class TestCase(unittest.TestCase):
    def setUp(self):
        os.environ['RECAPTCHA_DISABLE'] = 'True'

    def test_myform(self):
        form = MyForm({
            'field1': 'field1_value'
        })
        self.assertTrue(form.is_valid())

    def tearDown(self):
        del os.environ['RECAPTCHA_DISABLE']

django-recaptcha2's People

Contributors

alessandrobattisti avatar bernhardposselt avatar ckrybus avatar dwarni avatar kbytesys avatar lanny avatar mr-africa avatar nando-bog avatar xyene avatar za avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-recaptcha2's Issues

Not compatible with Django 2.1

My form, which uses django-crispy-forms and django-recaptcha2, has suddenly stopped working after I updated to 1.0.3 of django-recaptcha2 and 1.7.2 of django-crispy-forms.

Here is the traceback (I've replaced the name of the project and omitted my home directory for privacy reasons):

Traceback (most recent call last):
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "~/Git/django-project/app/views/SignupView.py", line 21, in SignupView
    "form": form
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/shortcuts.py", line 36, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 987, in render
    output = self.filter_expression.resolve(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 698, in resolve
    new_obj = func(obj, *arg_vals)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/crispy_forms/templatetags/crispy_forms_filters.py", line 66, in as_crispy_form
    return template.render(c)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/crispy_forms/templatetags/crispy_forms_utils.py", line 34, in render
    return remove_spaces(self.nodelist.render(context).strip())
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/defaulttags.py", line 209, in render
    nodelist.append(node.render_annotated(context))
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/loader_tags.py", line 188, in render
    return template.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 173, in render
    return self._render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/defaulttags.py", line 309, in render
    return nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/defaulttags.py", line 309, in render
    return nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/defaulttags.py", line 309, in render
    return nodelist.render(context)
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/template/base.py", line 940, in render
    bits.append(str(bit))
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/utils/html.py", line 397, in <lambda>
    klass.__str__ = lambda self: mark_safe(klass_str(self))
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/forms/boundfield.py", line 33, in __str__
    return self.as_widget()
  File "~/.local/share/virtualenvs/django-project-1vOU-KL3/lib/python3.6/site-packages/django/forms/boundfield.py", line 93, in as_widget
    renderer=self.form.renderer,

Please let me know if you need any additional information. Thank you! Your work is appreciated!

recaptcha_host variable is passed to the wrong tag

In the current version of recaptcha2 the recaptcha_host variable is passed to the wrong tag (recaptcha_invisible_button), so recaptcha_init tries to include the api.js from the site directly instead of the value specified in RECAPTCHA_PROXY_HOST or https://google.com

I will do a Pull request which fixes the problem.

Unable to render captcha for multiple forms on a single page

I have multiple user registration forms on a single page. The captcha is getting rendered for only first form on the page and not for others. Even though I have set explicit=True in forms.py and have also included
{% recaptcha_explicit_support %} and {% recaptcha_explicit_init %} in the template.

Load recaptcha script in the widget template

On pages where captcha display is conditional, in cases where no captcha is displayed, it would be nice to not load the captcha script. But if you're including {% recaptcha_init %} in a page's <head> tag you have to do the captcha check in two places. It would also make first time setup easier as you wouldn't need to edit any of your project templates to facilitate integration.

reCAPTCHA proxy support

recaptcha-init.html loads the reCAPTCHA script from https://google.com, which may be inaccessible for some users (notably, it is blocked in China).

https://recaptcha.net exists for this purpose, so it'd be great if there were out-of-the-box support for it (perhaps as a settings.py option). Currently we just override the recaptcha-init template, but it would be nicer if there was built-in support for it.

I would be happy to send a PR in for this if it'd be helpful.

Signup Form not showing the captcha field.

Hello,

I have a signup page with a form and added a captcha field, but it seems to be blank.

Django version 2.1

class SignUpForm(UserCreationForm):
captcha = ReCaptchaField(widget=ReCaptchaWidget())
def init(self, *args, **kwargs):
super(SignUpForm, self).init(*args, **kwargs)
for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'form-control'
class Meta:
model = CustomUser

While the template render it seems to show the captcha field name but the actual captcha doesnt render at all. There are no messages showing.

Allow passing reCaptcha settings in field constructor

praekelt/django-recaptcha (which it looks like this project follows the API of pretty closely) allows you to pass private_key and public_key kwargs when constructing a new ReCaptchaField as opposed to using keys in settings. This was nice because it allowed more than one set of keys to be used per project and let you defer the selection of a keyset for a form until runtime. It would be nice to see the same feature here.

KeyError 'error-codes'

On line https://github.com/kbytesys/django-recaptcha2/blob/master/snowpenguin/django/recaptcha2/fields.py#L47 we crash if 'error-codes' is not defined in the json data. I think this might have happened as a result of some sort of glitch with Google servers.

Traceback:

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/lib64/python3.4/contextlib.py" in inner
  30.                 return func(*args, **kwds)

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/opt/python/current/app/facs/formtest/views.py" in dispatch
  552.         return super(RegistrationView, self).dispatch(request, *args, **kwargs)

File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/account/views.py" in dispatch
  69.                                             **kwargs)

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/account/views.py" in post
  84.         if form.is_valid():

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/forms/forms.py" in is_valid
  161.         return self.is_bound and not self.errors

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/forms/forms.py" in errors
  153.             self.full_clean()

File "/opt/python/run/venv/lib/python3.4/site-packages/django_superform/forms.py" in full_clean
  220.         super(SuperFormMixin, self).full_clean()

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/forms/forms.py" in full_clean
  362.         self._clean_fields()

File "/opt/python/run/venv/lib64/python3.4/site-packages/django/forms/forms.py" in _clean_fields
  380.                     value = field.clean(value)

File "/opt/python/run/venv/lib/python3.4/site-packages/snowpenguin/django/recaptcha2/fields.py" in clean
  47.             if 'missing-input-secret' in json_response['error-codes'] or \

Exception Type: KeyError at ...
Exception Value: 'error-codes'
Request information:
GET: No GET data

Missing __init__ in namespace packages

Hi,

thanks for this great package !

I have found a few minor issues when running with python -Wall, namely:

\Python36\lib\importlib\_bootstrap_external.py:426: ImportWarning: Not importing directory env\lib\site-packages\snowpenguin: missing __init__
  _warnings.warn(msg.format(portions[0]), ImportWarning)

\Python36\lib\importlib\_bootstrap_external.py:426: ImportWarning: Not importing directory env\lib\site-packages\snowpenguin\django: missing __init__
  _warnings.warn(msg.format(portions[0]), ImportWarning)

# Repeated about 20 times ...

I'm not sure how severe this is, but at least it pollutes the console output, so probably this would be worth fixing ?

Cheers,
Lorcan

rendring multi invsible recptha in one page

i have multi forms in one page i try to render multi invisible recapcha but not work with me how can and when I try to follow way on wiki i got error closed tag? can any exmple or something to help me

Reload on ajax

How to reload this plugin after ajax request?

$('#id_input').keyup(function(e){
        let url = index_url;
        $.ajax({
            type: "POST",
            url: url,
            data: {
                'input': $('#id_input').val(),
                'offer_type': $('#id_offer_type').val(),
                'category': $('#id_category').val()
            },
            success: function (data) {
                $('#offer-objects').html(data);
            },
            complete: function(){
                SwiperReload();
            },
        });
    });

Something like that. If recaptcha is inside div with ID offer objects (#offerobjects) it does not load after ajax request finished (inside success function).

Any ideas?

white space error

If I set type="audio" in the widget, then I get data-type="audio " in the resultant HTML which does not work due to the extra space.

Looking at recaptcha_automatic.html I see the space before the quotes, think it needs to go after the quotes.

I suspect this isn't going to be required for my project however I thought I should let you know anyway.

diff --git a/snowpenguin/django/recaptcha2/templates/snowpenguin/recaptcha/recaptcha_automatic.html b/snowpenguin/django/recaptcha2/templates/snowpenguin/recaptcha/recaptcha_automatic.html
index 0973024..a873026 100644
--- a/snowpenguin/django/recaptcha2/templates/snowpenguin/recaptcha/recaptcha_automatic.html
+++ b/snowpenguin/django/recaptcha2/templates/snowpenguin/recaptcha/recaptcha_automatic.html
@@ -1 +1 @@
-<div class="g-recaptcha" id="{{ container_id }}" data-sitekey="{{ public_key }}" {% if theme %}data-theme="{{ theme }} "{% endif %}{% if type %}data-type="{{ type }} "{% endif %}{% if size %}data-size="{{ size }} "{% endif %}{% if tabindex %}data-tabindex="{{ tabindex }} "{% endif %}{% if callback %}data-callback="{{ callback }} "{% endif %}{% if expired_callback %}data-expired-callback="{{ expired_callback }}"{% endif %}></div>
\ No newline at end of file
+<div class="g-recaptcha" id="{{ container_id }}" data-sitekey="{{ public_key }}" {% if theme %}data-theme="{{ theme }}" {% endif %}{% if type %}data-type="{{ type }}" {% endif %}{% if size %}data-size="{{ size }}" {% endif %}{% if tabindex %}data-tabindex="{{ tabindex }}" {% endif %}{% if callback %}data-callback="{{ callback }}" {% endif %}{% if expired_callback %}data-expired-callback="{{ expired_callback }}"{% endif %}></div>

Testing

Is there a way to disable to the app for testing? or a way to included in testing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.