'Create a new Tag of the base type associated with this
object.  This makes sure to create case-insensitive tags.
If the exact same tag configuration (key+category+tagtype+dbmodel)
exists on the model, a new tag will not be created, but an old
one returned.
Args:
key (str, optional): Tag key. Not case sensitive.
category (str, optional): Tag category. Not case sensitive.
data (str, optional): Extra information about the tag.
tagtype (str or None, optional): \'type\' of Tag, by default
this is either `None` (a normal Tag), `alias` or
`permission`.
Notes:
The `data` field is not part of the uniqueness of the tag:
Setting `data` on an existing tag will overwrite the old
data field. It is intended only as a way to carry
information about the tag (like a help text), not to carry
any information about the tagged objects themselves.'

def create_tag(self, key=None, category=None, data=None, tagtype=None):

    data = (str(data) if (data is not None) else None)
    dbmodel = self.model.__dbclass__.__name__.lower()
    tag = self.get_tag(key=key, category=category, tagtype=tagtype, global_search=True)
    if (tag and (data is not None)):
        tag = tag[0]
        tag.db_data = data
        tag.save()
    elif (not tag):
        global _Tag
        if (not _Tag):
            from evennia.typeclasses.models import Tag as _Tag
        tag = _Tag.objects.create(db_key=(key.strip().lower() if (key is not None) else None), db_category=(category.strip().lower() if (category and (key is not None)) else None), db_data=data, db_model=dbmodel, db_tagtype=(tagtype.strip().lower() if (tagtype is not None) else None))
        tag.save()
    return make_iter(tag)[0]
