Skip to content

Upate all uniqueness validation to employ UniqueConstraint classes #10361

Closed
@jeremystretch

Description

@jeremystretch

Proposed Changes

Replace all instances of unique_together under a model Meta class with a list of UniqueConstraint instances defined under constraints. Additionally, and custom overrides of a model's validate_unique() method should be removed where possible.

Justification

UniqueConstraint was introduced in Django 4.0 and allows for conditional evaluation. This should allow us to ditch any custom validate_unique() logic, such as what is currently defined for the Device model. The Django docs also recommend moving away from unique_together in general as it will likely be deprecated in the future.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: housekeepingChanges to the application which do not directly impact the end user

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions