1👍
Instead of defining it at DB level, you can use uuid from python as default value for the uuid field.
import uuid
def get_uuid():
return str(uuid.uuid4())
class myTable(models.Model):
id = models.AutoField(primary_key=True)
myuuid = models.CharField(max_length=40, unique=True, default=get_uuid)
anotherColumn = models.CharField(max_length=40)
class Meta:
db_table = "myTable"
Source:stackexchange.com