mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Fix: editing of existing custom fields violates throws unique error
This commit is contained in:
parent
0deb8a11d6
commit
7fe76656f2
@ -463,7 +463,14 @@ class CustomFieldSerializer(serializers.ModelSerializer):
|
||||
"name",
|
||||
self.instance.name if hasattr(self.instance, "name") else None,
|
||||
)
|
||||
if ("name" in attrs) and self.Meta.model.objects.filter(
|
||||
objects = (
|
||||
self.Meta.model.objects.exclude(
|
||||
pk=self.instance.pk,
|
||||
)
|
||||
if self.instance is not None
|
||||
else self.Meta.model.objects.all()
|
||||
)
|
||||
if ("name" in attrs) and objects.filter(
|
||||
name=name,
|
||||
).exists():
|
||||
raise serializers.ValidationError(
|
||||
|
Loading…
x
Reference in New Issue
Block a user