没有名为'django_auth_ldap'的模块

时间:2017-05-29 15:43:50

标签: django python-3.x authentication ldap django-auth-ldap

我正在尝试使用django和LDAP身份验证来配置网站。在我的登录页面上,我只输入任何用户名和密码,并希望到达不同的html页面(暂时不连接到数据库。我的view.py文件中的方法:

def login_view(request):
    if request.POST:
        print ('*'*50)
        print (request.POST)
        print ('*'*50)
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        print ('*'*50)
        print (user)
        print ('*'*50)
        if user is not None:
            if user.is_active:
                login(request, user)
                return redirect('index')
            else:
                messages.error(request, "User is not active in Database") 
        else:
            messages.error(request, "Please check your username and password!")
    return render(request, 'login.html')

我是django的新手,所以甚至不确定我是否应该看到这个错误消息是否正确的任何页面。我正在使用Python3.5并且我成功安装了pyasn1-0.2.3。然后进入我的控制台我可以成功import ldap3。但是我不能比这更进一步。

settings.py

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

任何我的目录都是这样的:

UserAuth
  -> user_auth
  -> UserAuth
  manage.py

根据我的推断,似乎无法轻松安装django_ldap_auth 1. Windows 8.1 Enterprise和2. for Python 3(https://github.com/susundberg/django-auth-ldap-ad

这很烦人,也许如果我切换到Python2,也许这会起作用....

1 个答案:

答案 0 :(得分:0)

我已经死了,除非我听到相反的情况,那么对于Windows上的Python3用户来说,这也将成为一个死胡同。可以找到关于此问题的主题here

相反,我现在尝试使用Radius。

相关问题