mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Owner/name unique constraint violation should exclude self
This commit is contained in:
		| @@ -78,10 +78,11 @@ class MatchingModelSerializer(serializers.ModelSerializer): | ||||
|             if hasattr(self, "user") | ||||
|             else None | ||||
|         ) | ||||
|         pk = self.instance.pk if hasattr(self.instance, "pk") else None | ||||
|         if ("name" in data or "owner" in data) and self.Meta.model.objects.filter( | ||||
|             name=name, | ||||
|             owner=owner, | ||||
|         ).exists(): | ||||
|         ).exclude(pk=pk).exists(): | ||||
|             raise serializers.ValidationError( | ||||
|                 {"error": "Object violates owner / name unique constraint"}, | ||||
|             ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon