def realize_deferred_projections(sender, *args, **kwargs): """Project any fields which were deferred pending model preparation.""" app_label = sender._meta.app_label model_name = sender.__name__.lower() pending = _DEFERRED_PROJECTIONS.pop((app_label, model_name), {}) for view_cls, field_names in pending.items(): field_instances = get_fields_by_name(sender, *field_names) for name, field in field_instances.items(): # Only assign the field if the view does not already have an # attribute or explicitly-defined field with that name. if hasattr(view_cls, name) or hasfield(view_cls, name): continue copy.copy(field).contribute_to_class(view_cls, name)
def realize_deferred_projections(sender, *args, **kwargs): """Project any fields which were deferred pending model preparation.""" app_label = sender._meta.app_label model_name = sender.__name__.lower() pending = _DEFERRED_PROJECTIONS.pop((app_label, model_name), {}) for view_cls, field_names in pending.items(): field_instances = get_fields_by_name(sender, *field_names) for name, field in field_instances.items(): # Only assign the field if the view does not already have an # attribute or explicitly-defined field with that name. if hasattr(view_cls, name) or hasfield(view_cls, name): continue copy.copy(field).contribute_to_class(view_cls, name)