﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36070	"clean_fields(exclude=[""pk""]) not implemented for composite primary keys"	Jacob Walls	Jacob Walls	"Passing `exclude=[""pk""]` to `full_clean()` / `clean_fields()` has no effect: the underlying fields have to be provided instead.

This ""no effect"" might be silent (coercing a value when you didn't expect) or loud (raising ValidationError) given that we don't raise `ValueError` for providing an extraneous field name.

I'm suggesting we either implement `exclude=[""pk""]` to exclude all the composed fields or raise `ValueError`. Raising an error might be wiser?

Failing test:
{{{#!diff
diff --git a/tests/composite_pk/test_models.py b/tests/composite_pk/test_models.py
index ca6ad8b5dc..ed54d6c352 100644
--- a/tests/composite_pk/test_models.py
+++ b/tests/composite_pk/test_models.py
@@ -118,6 +118,10 @@ class CompositePKModelsTests(TestCase):
 
                 self.assertSequenceEqual(ctx.exception.messages, messages)
 
+    def test_clean_fields_exclude_pk(self):
+        post = Token()
+        post.clean_fields(exclude=[""pk""])
+
     def test_field_conflicts(self):
         test_cases = (
             ({""pk"": (1, 1), ""id"": 2}, (1, 1)),
}}}
{{{
======================================================================
ERROR: test_clean_fields_exclude_pk (composite_pk.test_models.CompositePKModelsTests.test_clean_fields_exclude_pk)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/Users/.../django/tests/composite_pk/test_models.py"", line 123, in test_clean_fields_exclude_pk
    post.clean_fields(exclude=[""pk""])
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File ""/Users/.../django/django/db/models/base.py"", line 1708, in clean_fields
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'tenant': ['This field cannot be null.'], 'id': ['This field cannot be null.']}

----------------------------------------------------------------------
}}}"	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
