代码之家  ›  专栏  ›  技术社区  ›  t0bi

没有名为“django_python3_ldap”的模块

  •  0
  • t0bi  · 技术社区  · 8 年前

    我想使用活动目录对用户进行身份验证。为了在我的项目中支持此功能,我使用了“django-python3-ldap”框架。但是,我收到了错误 ModuleNotFoundError: No module named 'django_python3_ldap'

    全球_设置.py

    AUTHENTICATION_BACKENDS = ['django_python3_ldap.auth.LDAPBackend']
    

    设置.py

    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    'website', 'django_python3_ldap',
    ]
    
    # Authentication Backend
    
    AUTHENTICATION_BACKENDS = ('django_python3_ldap.auth.LDAPBackend',)
    
    # Django-Python3-LDAP Authentication
    
    LDAP_AUTH_URL = "ldap://<my_domain>.com:389"
    
    LDAP_AUTH_SEARCH_BASE = "ou=people,dc=<my_domain>,dc=com"
    
    LDAP_AUTH_OBJECT_CLASS = "inetOrgPerson"
    
    LDAP_AUTH_USER_FIELDS = {
        "username": "sAMAccountName",
        "first_name": "givenName",
        "last_name": "sn",
        "email": "mail",
    }
    
    LDAP_AUTH_USER_LOOKUP_FIELDS = ("username",)
    
    LDAP_AUTH_CLEAN_USER_DATA = "django_python3_ldap.utils.clean_user_data"
    
    LDAP_AUTH_FORMAT_USERNAME =  "django_python3_ldap.utils.format_username_active_directory"
    
    0 回复  |  直到 8 年前