[Answered ]-Django: How to make Id unique between 2 different model classes

1👍

As Vishal Singh commented, the UUIDField class from Django’s Model can be used to create

A field for storing universally unique identifiers.

As mentioned here.

Usage could be as following:

import uuid
from django.db import models


class Customer(models.Model):
    id_ = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    name = models.CharField(max_length=255)


class OnlineCustomer(models.Model):
    id_ = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    name = models.CharField(max_length=255)

Leave a comment