#29258: Better error message for passing authentication backend class where 
string
expected
-----------------------------------------+------------------------
               Reporter:  Ryan Govostes  |          Owner:  nobody
                   Type:  New feature    |         Status:  new
              Component:  contrib.auth   |        Version:  2.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  1
                  UI/UX:  0              |
-----------------------------------------+------------------------
 I had written

 {{{
 from django.contrib.auth.backends import ModelBackend
 ...
 login(request, user, backend=ModelBackend)
 }}}

 which generated a very bizarre exception "Object of type 'type' is not
 JSON serializable" from the sessions middleware with no backtrace leading
 back to my code.

 In the documentation for "Selecting the authentication backend", it says:
 "the value of the backend argument or the user.backend attribute should be
 a dotted import path string (like that found in AUTHENTICATION_BACKENDS),
 not the actual backend class."

 It would be nice to catch this, e.g., `assert isinstance(backend, str)`
 closer to the site of the mistake.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29258>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/047.74ff538dceaa6aebe41a0c4fec0df8ca%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to