Skip to content

ImportError: cannot import name 'ReCaptchaField #14

@DeveloperHarris

Description

@DeveloperHarris
  • Django REST framework reCAPTCHA version: 0.2.0
  • Django REST framework version: DRF 3.9.1
  • Django version: Django 2.1.5
  • Python version: Python 3.6.5
  • Operating System: Windows 10

Description

I followed the installation instructions: installed package through pip, added it to my django installed apps, created a setting which contained my recaptcha secret key, and then imported it into my serializer classes.

Pip screenshot: Image

Installed Apps: Image

What I Did

Serializers.py

from django.contrib.auth.models import User
from scrimhub.models import Team, Post, Confirmation
from rest_framework import serializers
from rest_framework_recaptcha import ReCaptchaField


class UserSerializer(serializers.HyperlinkedModelSerializer):
    recaptcha = ReCaptchaField()

    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'groups')
...
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03D777C8>
Traceback (most recent call last):
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 396, in check
    for pattern in self.url_patterns:
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\vortex\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\vortex\django\ScuttleScrims\scuttlescrims\urls.py", line 20, in <module>
    from . import views
  File "C:\Users\vortex\django\ScuttleScrims\scuttlescrims\views.py", line 5, in <module>
    from .serializers import UserSerializer, TeamSerializer, PostSerializer, ConfirmationSerializer
  File "C:\Users\vortex\django\ScuttleScrims\scuttlescrims\serializers.py", line 4, in <module>
    from rest_framework_recaptcha import ReCaptchaField
ImportError: cannot import name 'ReCaptchaField'```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions