models.py:
class PageURL(models.Model):
url = models.TextField(max_length=2048, unique=True)
Error during migrations:
django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'url' used in key specification without a key length")
I considered a CharField but Django said the max on that for this use case was 255 characters. Initially I just had TextField(unique=True)
but decided to add a max_length which I heard was normally 2048 for URLs but that hasn't helped silence the errors.
I tried CharField with no max_length and just a unique constraint set.
core.PageURL.url: (fields.E120) CharFields must define a 'max_length' attribute. core.PageURL.url: (mysql.E001) MySQL does not allow unique CharFields to have a max_length > 255.
The solution I've rigged is to go into phpMyAdmin and alter the structure by hand to varchar(2048) and add a unique constraint to it.