Fix unique_together validation with source by yuekui · Pull Request #9482 · encode/django-rest-framework (original) (raw)

gergosimonyi added a commit to goauthentik/authentik that referenced this pull request

Apr 14, 2025

@gergosimonyi

upgrade django-rest-framework to 3.16.0

The reverted commit is purely an optimization which unfortunately breaks authentik, specifically Blueprints. It adds getattr(serializer.instance, field) to a validator. If field is a RelatedObject, that invocation queries the database.

When authentik creates objects using Blueprints, it doesn't place related objects into the database before the validator tries to get them from there, so with the reverted commit, it produces RelatedObjectDoesNotExist.

Perhaps a long-term solution is to revise how Blueprints work, or perhaps it is to change upstream. But in the meantime, Django 5.0 support ended and upgrading to Django 5.1 requires an upgrade of django-rest-framework to 3.16.0, hence this workaround.

See