diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf58edec..956dd617 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/PyCQA/bandit - rev: 1.7.7 + rev: 1.7.8 hooks: - id: bandit args: diff --git a/simple_history/models.py b/simple_history/models.py index a4b92271..9ff107a9 100644 --- a/simple_history/models.py +++ b/simple_history/models.py @@ -4,6 +4,7 @@ import warnings from functools import partial +import django from django.apps import apps from django.conf import settings from django.contrib import admin @@ -813,6 +814,13 @@ def transform_field(field): # Unique fields can no longer be guaranteed unique, # but they should still be indexed for faster lookups. field.primary_key = False + # DEV: Remove this check (but keep the contents) when the minimum required + # Django version is 5.1 + if django.VERSION >= (5, 1): + field.unique = False + # (Django < 5.1) Can't set `unique` as it's a property, so set the backing field + # (Django >= 5.1) Set the backing field in addition to the cached property + # above, to cover all bases field._unique = False field.db_index = True field.serialize = True