Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#15532 closed (fixed)

Improve error message for django.contrib.auth.load_backend

Reported by: Mikhail Korobov Owned by: nobody
Component: contrib.auth Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hi all,

If backend can't be imported for some reason, it now raises the following message (see django.contrib.auth.__init__.py):

    except ImportError, e:
        raise ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (module, e))

This message contains module name. I think it is a good idea to change this to full backend name in order to simplify debugging:

    except ImportError, e:
        raise ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (path, e))

My case: custom django-registration registration backend (with supplying auth backend) that sets user.backend to wrong value (import path was incorrect, class name was correct). It was not easy to determine from existing error message which auth backend is failing because backend class name wasn't in error message.

Change History (3)

comment:1 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedReady for checkin

comment:2 Changed 6 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

In [15713]:

Fixed #15532 -- Clarified the error message for unknown auth backends. Thanks to kmike for the report.

comment:3 Changed 6 years ago by Russell Keith-Magee

In [15715]:

[1.2.X] Fixed #15532 -- Clarified the error message for unknown auth backends. Thanks to kmike for the report.

Backport of r15713 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top