Skip to content

Instantly share code, notes, and snippets.

@ychennay
Created March 18, 2020 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ychennay/cedeb6990fe6eaaf76a32130c955581a to your computer and use it in GitHub Desktop.
Save ychennay/cedeb6990fe6eaaf76a32130c955581a to your computer and use it in GitHub Desktop.
private fields
# Inherit private fields (like GenericForeignKey) from the parent
# class
for field in base._meta.private_fields:
if field.name in field_names:
if not base._meta.abstract:
raise FieldError(
'Local field %r in class %r clashes with field of '
'the same name from base class %r.' % (
field.name,
name,
base.__name__,
)
)
else:
field = copy.deepcopy(field)
if not base._meta.abstract:
field.mti_inherited = True
new_class.add_to_class(field.name, field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment