Parses the value of EXTRA_MODEL_FIELDS, grouping the entries by model
    and instantiating the extra fields. Returns a sequence of tuples of
    the form (model_key, fields) where model_key is a pair of app_label,
    model_name and fields is a list of (field_name, field_instance) pairs.

def parse_extra_model_fields(extra_model_fields):
    """
    Parses the value of EXTRA_MODEL_FIELDS, grouping the entries by model
    and instantiating the extra fields. Returns a sequence of tuples of
    the form (model_key, fields) where model_key is a pair of app_label,
    model_name and fields is a list of (field_name, field_instance) pairs.
    """
    fields = defaultdict(list)
    for entry in extra_model_fields:
        model_key, field_name = parse_field_path(entry[0])
        field_class = import_field(entry[1])
        field_args, field_kwargs = entry[2:]
        try:
            field = field_class(*field_args, **field_kwargs)
        except TypeError as e:
            raise ImproperlyConfigured(
                "The EXTRA_MODEL_FIELDS setting contains arguments for the "
                "field '%s' which could not be applied: %s" % (entry[1], e))
        fields[model_key].append((field_name, field))
    return fields