﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24437	contrib.auth @ 1.8b1 breaks existing projects / applications using Mongoengine	Carsten Klein	nobody	"The following changes in django/contrib/auth/__init__.py

{{{
root@J101829:/tmp# diff dj18a1/contrib/auth/__init__.py dj18b1/contrib/auth/__init__.py
55a56,62
> def _get_user_session_key(request):
>     # This value in the session is always serialized to a string, so we need
>     # to convert it back to Python whenever we access it.
>     raise Exception(get_user_model())
>     return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
> 
> 
96c103
<         if request.session[SESSION_KEY] != user.pk or (
---
>         if _get_user_session_key(request) != user.pk or (
105c112
<     request.session[SESSION_KEY] = user.pk
---
>     request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)
161c168
<         user_id = request.session[SESSION_KEY]
---
>         user_id = _get_user_session_key(request)
}}}



break existing applications / projects using Mongoengine.

Mongoengine installs a custom MongoUser that is a shim around the actual model, which is a mongoengine document. The actual user id is a hexadecimal number / string and might not be validated using int(), causing the following exception

{{{
ValidationError at /backend/admin/
[u'\u201a511a1da669fe60752b000000\u201b Wert muss eine Ganzzahl sein.']
Request Method:	GET
Request URL:	http://XXX/login
Django Version:	1.8b1
Exception Type:	ValidationError
Exception Value:	
[u'\u201a511a1da669fe60752b000000\u201b Value must be an int.']
Exception Location:	/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py in to_python, line 969
Python Executable:	/usr/bin/uwsgi-core
Python Version:	2.7.8
}}}


I do not know whether django.contrib.auth should make any assumption on the actual type of the id, or whether mongoengine should reimplement the pk property and delegate to its own version of the Auto field.


See here for the bug I filed against mongoengine: https://github.com/MongoEngine/mongoengine/issues/899"	Bug	new	contrib.auth	1.8beta1	Normal			github.vibepy@…	Unreviewed	0	0	0	0	0	0
