﻿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
28575	Model.DoesNotExist classes are not pickleable	Rachel Tobin	nobody	"Example:
{{{
>>> import django
>>> import pickle
>>> pickle.dumps(django.contrib.auth.models.User.DoesNotExist)
>>> PicklingError: Can't pickle <class 'django.contrib.auth.models.DoesNotExist'>: it's not found as django.contrib.auth.models.DoesNotExist
}}}

Note that *instances* of `Model.DoesNotExist` are pickleable as fixed here: https://code.djangoproject.com/ticket/17776. However the class itself is not.  This is particularly problematic when using the Django test runner with the `--parallel` option enabled when a `Model.DoesNotExist` exception is raised. The result of this is the test runner bailing with a `pickle.PicklingError`, making it exceptionally difficult to debug the cause of the `Model.DoesNotExist`.

This could be fixed by changing the metaclass that is used here: https://github.com/django/django/blob/1.11.5/django/db/models/base.py#L76 to use a custom metaclass with a `__reduce__` method. A patch is in progress for this."	Uncategorized	new	Database layer (models, ORM)	1.11	Normal				Unreviewed	0	0	0	0	0	0
