Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#15532 closed (fixed)

Improve error message for django.contrib.auth.load_backend

Reported by: kmike 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 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

In [15713]:

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

comment:3 Changed 4 years ago by russellm

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