1

Is it possible to convert back from UUID to Django's default ID?

  • Could there be any impact in the existing data?
  • If I delete this line in my Model, Django could automatically add a field to hold the primary key?
  • Any thoughts on this or previous experience?
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Jorge
  • 105
  • 9
  • Replacing the primary key is not an easy thing to do. You need to check all the references before you want to replace PK. Is this only model or do you have some other models that user ID from your model as Foreign Key? – Aleksandar Varicak Jun 17 '22 at 14:08
  • This is the only blog i have found so far regarding this topic. https://luanjpb.medium.com/how-to-change-django-primary-key-from-uuid-to-integer-bf977232cec3 – Jorge Jun 20 '22 at 12:24

0 Answers0