def copy_fields(self, model):
        fields = {'__module__' : model.__module__}

        for field in model._meta.fields:

            if not field.name in self._exclude:

                field  = copy.deepcopy(field)

                if isinstance(field, models.AutoField):
                    #we replace the AutoField of the original model
                    #with an IntegerField because a model can
                    #have only one autofield.

                    field.__class__ = models.IntegerField

                if field.primary_key:
                    field.serialize = True

                #OneToOne fields should really be tracked
                #as ForeignKey fields
                if isinstance(field, models.OneToOneField):
                    field.__class__ = models.ForeignKey


                if field.primary_key or field.unique:
                    #unique fields of the original model
                    #can not be guaranteed to be unique
                    #in the audit log entry but they
                    #should still be indexed for faster lookups.

                    field.primary_key = False
                    field._unique = False
                    field.db_index = True


                if field.rel and field.rel.related_name:
                    field.rel.related_name = '_auditlog_%s' % field.rel.related_name                
                elif field.rel: 
                    try:
                        if field.rel.get_accessor_name():
                            field.rel.related_name = '_auditlog_%s' % field.rel.get_accessor_name()
                    except:
                        pass
  
                fields[field.name] = field

        return fields
Creates copies of the fields we are keeping
dataset/ETHPy150Open Atomidata/django-audit-log/audit_log/models/managers.py/AuditLog.copy_fields