#27524: Using user instance (instead of get_user_model()) leads to errors when
user
model is overridden
-----------------------------------------+------------------------
Reporter: Andy Martin | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
We've been seeing errors like this on 1.8.16:
{{{
File "[...snip...]/django/contrib/auth/__init__.py", line 111, in login
request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)
AttributeError: 'MetaDict' object has no attribute 'pk'
}}}
We solved them by going through the object returned by get_user_model()
instead of using the user instance directly. This also matches what's done
in other parts of the codebase (for example, in
_get_user_session_key(request)).
--
Ticket URL: <https://code.djangoproject.com/ticket/27524>
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/057.1c8d49bdf45faf8dc50a50b2aed58263%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.