docs: def restore(self, **kwargs):
          """
          Restores this version as a new version, and returns this new version.
  
          If a current version already exists, it will be terminated before
          restoring this version.
  
          Relations (foreign key, reverse foreign key, many-to-many) are not
          restored with the old version.  If provided in kwargs,
          (Versioned)ForeignKey fields will be set to the provided values.
          If passing an id for a (Versioned)ForeignKey, use the field.attname.
          For example:
             restore(team_id=myteam.pk)
          If passing an object, simply use the field name, e.g.:
             restore(team=myteam)
  
          If a (Versioned)ForeignKey is not nullable and no value is provided
          for it in kwargs, a ForeignKeyRequiresValueError will be raised.
  
          :param kwargs: arguments used to initialize the class instance
          :return: Versionable
          """
          if not self.pk:
              raise ValueError(
                  'Instance must be saved and terminated before it can be '
                  'restored.')
  
          if self.is_current:
              raise ValueError(
                  'This is the current version, no need to restore it.')
  
          if self.get_deferred_fields():
              # It would be necessary to fetch the record from the database
              # again for this to succeed.
              # Alternatively, perhaps it would be possible to create a copy
              # of the object after fetching the missing fields.
              # Doing so may be unexpected by the calling code, so raise an
              # exception: the calling code should be adapted if necessary.
              raise ValueError(
                  'Can not restore a model instance that has deferred fields')
  
          cls = self.__class__
          now = get_utc_now()
          restored = copy.copy(self)
          restored.version_end_date = None
          restored.version_start_date = now
  
          fields = [f for f in cls._meta.local_fields if
                    f.name not in Versionable.VERSIONABLE_FIELDS]
          for field in fields:
              if field.attname in kwargs:
                  # Fake an object in order to avoid a DB roundtrip
                  # This was made necessary, since assigning to the field's
                  # attname did not work anymore with Django 2.0
                  obj = field.remote_field.model(id=kwargs[field.attname])
                  setattr(restored, field.name, obj)
              elif field.name in kwargs:
                  setattr(restored, field.name, kwargs[field.name])
              elif isinstance(field, ForeignKey):
                  # Set all non-provided ForeignKeys to None.  If required,
                  # raise an error.
                  try:
                      setattr(restored, field.name, None)
                      # Check for non null foreign key removed since Django 1.10
                      # https://docs.djangoproject.com/en/1.10/releases/1.10/
                      # #removed-null-assignment-check-for-non-null-foreign-
                      # key-fields
                      if not field.null:
                          raise ValueError
                  except ValueError:
                      raise ForeignKeyRequiresValueError
  
          self.id = self.uuid()
  
          with transaction.atomic():
              # If this is not the latest version, terminate the latest version
              latest = cls.objects.current_version(self, check_db=True)
              if latest and latest != self:
                  latest.delete()
                  restored.version_start_date = latest.version_end_date
  
              self.save()
              restored.save()
  
              # Update ManyToMany relations to point to the old version's id
              # instead of the restored version's id.
              for field_name in self.get_all_m2m_field_names():
                  manager = getattr(restored,
                                    field_name)
                  # returns a VersionedRelatedManager instance
                  manager.through.objects.filter(
                      **{manager.source_field.attname: restored.id}).update(
                      **{manager.source_field_name: self})
  
              return restored