views:

29

answers:

1

I'm trying to use a custom authentication backend for a Django project I'm working on. My backend is based on the LDAPBackend found in the article LDAP Authentication in Django with Backends.

I'm getting the floowing error when I attempt to log in:

ImproperlyConfigured at /admin/ 
Module "challenge.backends" does not define a "LDAPBackend" authentication backend

My project is called "challenge". There is a subdirectory, "backends", which contains __init__.py and LDAPBackend.py.

My settings.py is configured to use this backend thusly:

AUTHENTICATION_BACKENDS = (
    'challenge.backends.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
)

I am able to import the module myself using python manage.py shell and then from challenge.backends import LDAPBackend.

I'm not sure what to check now since everything appears to be in the right place.

+2  A: 

You are importing it in wrong way. You are importing a module, rather than a class. That's why shell allows you to import it, but django complains.

You should use challenge.backends.LDAPBackend.LDAPBackend.

Also, it's a good idea to stick with PEP8 when naming modules, this way you won't be confused that way again. Modules should be names all in lowcase and without spaces, underscores, etc.

gruszczy
Worked like a charm. Thanks for the module naming reminder as well. I've already rectified that, too!
Zack Mulgrew
Glad I could help :-)
gruszczy