Created
March 18, 2020 03:54
-
-
Save ychennay/4934ec461c686768c7bd633e3eb215c4 to your computer and use it in GitHub Desktop.
Django subclasss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def subclass_exception(name, bases, module, attached_to): | |
""" | |
Create exception subclass. Used by ModelBase below. | |
The exception is created in a way that allows it to be pickled, assuming | |
that the returned exception class will be added as an attribute to the | |
'attached_to' class. | |
""" | |
return type(name, bases, { | |
'__module__': module, | |
'__qualname__': '%s.%s' % (attached_to.__qualname__, name), | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment