﻿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
29260	Django makes an extra UPDATE query when custom PK is evaluating before save.	user0007	nobody	"Using model's instance:

{{{

class Account(models.Model):
    id = models.UUIDField(
        primary_key=True,
        default=uuid.uuid4,
        editable=False
    )
    title = models.TextField()

>> account = Account()
>> account.title = ""abc""
>> account.save()

1. UPDATE ""app_account"" SET ""title"" = \'\', WHERE ""app_account"".""id"" = \'67c9327d-150e-419f-b493-0c2c59a045c3\'::uuid',
2. INSERT INTO ""app_account"" (""title"", ""id"") VALUES (\'abc\', \'3d8c1b3c-214a-4798-a0fa-d4c22c2b877f\'::uuid)

}}}

Using model's manager method:

{{{
>> Account.objects.create(title=""abc"")

1. INSERT INTO ""app_account"" (""title"", ""id"") VALUES (\'abc\', \'3d8c1b3c-214a-4798-a0fa-d4c22c2b877f\'::uuid)
}}}


Related issue? https://code.djangoproject.com/ticket/29129"	Bug	new	Database layer (models, ORM)	2.0	Normal				Unreviewed	0	0	0	0	0	0
