def make_uuid():
return str(uuid.uuid4())
and invoking it in models.py as the default on a character field, to make a uuid for each instance.
In both cases, I get warning when saving new instances that the data has been truncated. Even though it seems I can still use the truncated key, this warning makes, for example, my init fixtures fail as soon as they insert a uuid.
I found that, after creating my tables with the ORM, if I then go and manually adjust the character limit on a uuid field (say, from 36 to 40), then I don't get warnings, but I haven't tested this too far. However, I did test setting the character limit at 40 in advance, on a 36 character uuid field, and then building the tables, but this still ends up in data truncation warnings.
I am using MySQL. Any suggestions to implement uuid in a safe way, or what might be going wrong?
def make_uuid():
return str(uuid.uuid4())
should be:
def make_uuid():
return uuid.uuid4().hex