简体   繁体   中英

Error in adding django-axes to project

I have installed django axes with this command in cmd :

pip install django-axes

Then i addes to my setting.py file this parts :

    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'post_app',
    'axes',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'axes.middleware.FailedLoginMiddleware',
]

AXES_LOCK_OUT_AT_FAILURE = False
AXES_USE_USER_AGENT = True
AXES_COOLOFF_TIME = 1
AXES_LOGIN_FAILURE_LIMIT = 50

Now i want to runserver with this command :

python manage.py runserver

But i have this error in cmd :

  Unhandled exception in thread started by <function wrapper at 0x0000000004AA4908>
Traceback (most recent call last):
  File "D:\python\data\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "D:\python\data\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "D:\python\data\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
    six.reraise(*_exception)
  File "D:\python\data\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "D:\python\data\lib\site-packages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\python\data\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.ready()
  File "D:\python\data\lib\site-packages\axes\apps.py", line 9, in ready
    from axes.decorators import watch_login
  File "D:\python\data\lib\site-packages\axes\decorators.py", line 3, in <module>
    from socket import inet_pton, AF_INET6, error
ImportError: cannot import name inet_pton

Is there any mistake?or any missed work?

Did you run python manage.py migrate to sync the database before you run the server? If you did, then you need to check your python version and django verison, check this for detail: https://github.com/jazzband/django-axes/blob/master/.travis.yml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM