import uuid
import logging
from django.db import models
from django.contrib.auth.models import AbstractUser as DjangoAbstractUser

logger = logging.getLogger(__name__)


class AbstractUser(DjangoAbstractUser):
    uuid = models.UUIDField(primary_key=True)
    department_name = models.CharField(max_length=50, null=True, blank=True)

    def save(self, *args, **kwargs):
        if self.uuid is None:
            self.uuid = uuid.uuid1()
        return super(AbstractUser, self).save(*args, **kwargs)

    class Meta:
        abstract = True

import uuid
import logging
from django.db import models
from django.contrib.auth.models import AbstractUser as DjangoAbstractUser

logger = logging.getLogger(__name__)


class AbstractUser(DjangoAbstractUser):
    uuid = models.UUIDField()
    department_name = models.CharField(max_length=50, null=True, blank=True)

    def save(self, *args, **kwargs):
        if self.uuid is None:
            self.uuid = uuid.uuid1()
        return super(AbstractUser, self).save(*args, **kwargs)

    class Meta:
        abstract = True

Make UUID a non-pk to work around problems in 3rd party apps
Make UUID a non-pk to work around problems in 3rd party apps

  import uuid
  import logging
  from django.db import models
  from django.contrib.auth.models import AbstractUser as DjangoAbstractUser
  
  logger = logging.getLogger(__name__)
  
  
  class AbstractUser(DjangoAbstractUser):
-     uuid = models.UUIDField(primary_key=True)
+     uuid = models.UUIDField()
      department_name = models.CharField(max_length=50, null=True, blank=True)
  
      def save(self, *args, **kwargs):
          if self.uuid is None:
              self.uuid = uuid.uuid1()
          return super(AbstractUser, self).save(*args, **kwargs)
  
      class Meta:
          abstract = True
  
Make UUID a non-pk to work around problems in 3rd party apps
## Code Before:
import uuid
import logging
from django.db import models
from django.contrib.auth.models import AbstractUser as DjangoAbstractUser

logger = logging.getLogger(__name__)


class AbstractUser(DjangoAbstractUser):
    uuid = models.UUIDField(primary_key=True)
    department_name = models.CharField(max_length=50, null=True, blank=True)

    def save(self, *args, **kwargs):
        if self.uuid is None:
            self.uuid = uuid.uuid1()
        return super(AbstractUser, self).save(*args, **kwargs)

    class Meta:
        abstract = True

## Instruction:
Make UUID a non-pk to work around problems in 3rd party apps
## Code After:
import uuid
import logging
from django.db import models
from django.contrib.auth.models import AbstractUser as DjangoAbstractUser

logger = logging.getLogger(__name__)


class AbstractUser(DjangoAbstractUser):
    uuid = models.UUIDField()
    department_name = models.CharField(max_length=50, null=True, blank=True)

    def save(self, *args, **kwargs):
        if self.uuid is None:
            self.uuid = uuid.uuid1()
        return super(AbstractUser, self).save(*args, **kwargs)

    class Meta:
        abstract = True
