Skip to content

Presave signal fails when using UUID field as PK #131

@thommor

Description

@thommor

The pre_save signal fails when a model uses a UUID field as a primary key.

It seems that by the time the pre_save runs the UUID field already has a value meaning the easy audit thinks it is an update and tries to retrieve the original model from the database, which fails.

class Customer(ExportModelOperationsMixin('customer'), models.Model):
    """Model that represents a customer"""
    id = models.UUIDField(verbose_name='ID', primary_key=True, default=uuid.uuid4, editable=False, unique=True,
                          help_text='A UUID string identifying this customer')
    """The unique UUID of this :class:`Customer`"""

I think this is due to the fact that the UUID field has a default but this is required for UUID fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions