I am aware of a problem where pickle cannot store a generated or dynamic class. I solved this by binding my dynamic type to modules like this:
new_class = type(name, (models.Model,), attrs) mod = sys.modules[new_class.__module__] mod.__dict__[new_class.__name__] = new_class
This is a FAR from a clean or elegant solution, so if anyone can think of a more convenient way for Django to do this, Iβm all ears. However, the above code does work.
source share