Created
March 18, 2020 03:51
-
-
Save ychennay/268cad5b00ba98fb9b7f4746c8564271 to your computer and use it in GitHub Desktop.
Examples of dynamic exceptions
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
if not abstract: | |
new_class.add_to_class( | |
'DoesNotExist', | |
subclass_exception( | |
'DoesNotExist', | |
tuple( | |
x.DoesNotExist for x in parents if hasattr(x, '_meta') and not x._meta.abstract | |
) or (ObjectDoesNotExist,), | |
module, | |
attached_to=new_class)) | |
new_class.add_to_class('_meta', Options(meta, app_label)) | |
new_class.add_to_class( | |
'MultipleObjectsReturned', | |
subclass_exception( | |
'MultipleObjectsReturned', | |
tuple( | |
x.MultipleObjectsReturned for x in parents if hasattr(x, '_meta') and not x._meta.abstract | |
) or (MultipleObjectsReturned,), | |
module, | |
attached_to=new_class)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment