def __new__(mcs, name, bases, attrs):

    def get_double_name(name):
        suffix = '__hidden'
        slen = len(suffix)
        return (name[:(- slen)] if name.endswith(suffix) else (name + suffix))

    def make_clean_method(field_name):

        def _clean_method(self):
            value = self.cleaned_data[field_name]
            if value:
                self.cleaned_data[get_double_name(field_name)] = value
            return value
        return _clean_method
    new_attrs = {}
    for (attr_name, attr) in attrs.items():
        new_attrs[attr_name] = attr
        if isinstance(attr, ExternalFileField):
            hidden_field = fields.CharField(widget=fields.HiddenInput, required=False)
            hidden_field.creation_counter = (attr.creation_counter + 1000)
            new_attr_name = get_double_name(attr_name)
            new_attrs[new_attr_name] = hidden_field
            meth_name = ('clean_' + new_attr_name)
            new_attrs[meth_name] = make_clean_method(new_attr_name)
    return super(ExternalUploadMeta, mcs).__new__(mcs, name, bases, new_attrs)
def __new__(mcs, name, bases, attrs):

    def get_double_name(name):
        suffix = '__hidden'
        slen = len(suffix)
        return (name[:(- slen)] if name.endswith(suffix) else (name + suffix))

    def make_clean_method(field_name):

        def _clean_method(self):
            value = self.cleaned_data[field_name]
            if value:
                self.cleaned_data[get_double_name(field_name)] = value
            return value
        return _clean_method
    new_attrs = {}
    for (attr_name, attr) in attrs.items():
        new_attrs[attr_name] = attr
        if isinstance(attr, ExternalFileField):
            hidden_field = fields.CharField(widget=fields.HiddenInput, required=False)
            hidden_field.creation_counter = (attr.creation_counter + 1000)
            new_attr_name = get_double_name(attr_name)
            new_attrs[new_attr_name] = hidden_field
            meth_name = ('clean_' + new_attr_name)
            new_attrs[meth_name] = make_clean_method(new_attr_name)
    return super(ExternalUploadMeta, mcs).__new__(mcs, name, bases, new_attrs)