verbose_name_plural = _('Tokens')

def save(self, *args, **kwargs):
    if not self.key:
        self.key = self.generate_key()
return super(MyOwnToken, self).save(*args, **kwargs)

def generate_key(self):
    return binascii.hexlify(os.urandom(20)).decode()

def __str__(self):
    return self.key
How to use custom token model in Django Rest Framework