code: def save_form_data(self, instance, data):
          
          from yacms.generic.models import Keyword
          related_manager = getattr(instance, self.name)
          # Get a list of Keyword IDs being removed.
          old_ids = [str(a.keyword_id) for a in related_manager.all()]
          new_ids = data.split(",")
          removed_ids = set(old_ids) - set(new_ids)
          # Remove current AssignedKeyword instances.
          related_manager.all().delete()
          # Convert the data into AssignedKeyword instances.
          if data:
              data = [related_manager.create(keyword_id=i) for i in new_ids]
          # Remove keywords that are no longer assigned to anything.
          Keyword.objects.delete_unused(removed_ids)
          super(KeywordsField, self).save_form_data(instance, data)
docs: The ``KeywordsWidget`` field will return data as a string of
          comma separated IDs for the ``Keyword`` model - convert these
          into actual ``AssignedKeyword`` instances. Also delete
          ``Keyword`` instances if their last related ``AssignedKeyword``
          instance is being removed.