DataError: (1406, "Data too long for column 'name' at row 1")
Error:
DataError: (1406, "Data too long for column 'name' at row 1")
Problem Statement:
When creating a Slug in Django Model with Slugify this error populates.
Solution:
There are two solutions:
1. Don't use Symbols in Slug / autogenerated field like self.title
2. Import and use unidecode as follows:
from unidecode import unidecode #
from django.template import defaultfilters #
from django.utils.text import slugify # Old
Existing Code:
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(BlogPost, self).save(*args, **kwargs)
Updated Code:
def save(self, *args, **kwargs):
self.slug = defaultfilters.slugify(unidecode(self.title))
super(BlogCategory, self).save(*args, **kwargs)