﻿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
20289	Unpickling of dynamic model classes broken in 1.5	Anssi Kääriäinen	nobody	"The commit 146aff3bac974e56ec8cb597c2720d1cd4f77b26 broke unpickling of dynamically created models. This was reported in django-users thread http://groups.google.com/group/django-users/browse_thread/thread/1eee4a4d5098bfc5.

The problem is that deferred classes aren't only possible source of dynamically created class in Django. ManyToMany through class are dynamically created and in addition dynamic classes are possible in user code. My understanding is that user code dynamic classes should be supported, too.

I am not sure how to trigger this bug using standard Django models and fields. The django-users thread mentions this:
{{{
So for example, I have an instance of a Student, which has a
ForeignKey to Book, which in turn has a ManyToMany to Author.
If I try and cache my Student instance, I get that pickling
error.
}}}
but I haven't tested this.

I think resurrecting the simple_class_factory path of code instead of using `super.__reduce__` for the non deferred case is the right fix. Of course, the code comments need fixing, too, so just reverting the commit isn't a good idea.

Note that I haven't done any actual testing (no Django available on this machine...), so I will leave this unreviewed until I (or somebody else) will reproduce this using Django 1.5."	Bug	closed	Database layer (models, ORM)	1.5	Release blocker	fixed		Simon Charette	Accepted	0	0	0	0	0	0
