def add_field(self, field):
        # Insert the given field in the order in which it was created, using
        # the "creation_counter" attribute of the field.
        # Move many-to-many related fields from self.fields into
        # self.many_to_many.
        if field.rel and isinstance(field.rel, ManyToManyRel):
            self.local_many_to_many.insert(bisect(self.local_many_to_many, field), field)
            if hasattr(self, '_m2m_cache'):
                del self._m2m_cache
        else:
            self.local_fields.insert(bisect(self.local_fields, field), field)
            self.setup_pk(field)
            if hasattr(self, '_field_cache'):
                del self._field_cache
                del self._field_name_cache
                # The fields, concrete_fields and local_concrete_fields are
                # implemented as cached properties for performance reasons.
                # The attrs will not exists if the cached property isn't
                # accessed yet, hence the try-excepts.
                try:
                    del self.fields
                except __HOLE__:
                    pass
                try:
                    del self.concrete_fields
                except AttributeError:
                    pass
                try:
                    del self.local_concrete_fields
                except AttributeError:
                    pass

        if hasattr(self, '_name_map'):
            del self._name_map
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/django/db/models/options.py/Options.add_field