{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/52477396","id":52477396,"diff_hunk":"@@ -1790,12 +1790,16 @@ This has a number of caveats though:\n   ``post_save`` signals will not be sent.\n * It does not work with child models in a multi-table inheritance scenario.\n * If the model's primary key is an :class:`~django.db.models.AutoField` it\n-  does not retrieve and set the primary key attribute, as ``save()`` does.\n+  does not retrieve and set the primary key attribute, as ``save()`` does,\n+  unless the db backend also has the feature ``can_return_ids_from_bulk_insert``\n+  (currently ``postgresql``).\n * It does not work with many-to-many relationships.\n \n .. versionchanged:: 1.9\n \n     Support for using ``bulk_create()`` with proxy models was added.\n+    Support for setting primary keys on objects on bulk_create, when using","path":"docs/ref/models/querysets.txt","position":13,"original_position":13,"commit_id":"9156e386c6ed5e6468b6f6f4ce743e66b779f715","original_commit_id":"9156e386c6ed5e6468b6f6f4ce743e66b779f715","user":{"login":"timgraham","id":411869,"avatar_url":"https://avatars.githubusercontent.com/u/411869?v=3","gravatar_id":"","url":"https://api.github.com/users/timgraham","html_url":"https://github.com/timgraham","followers_url":"https://api.github.com/users/timgraham/followers","following_url":"https://api.github.com/users/timgraham/following{/other_user}","gists_url":"https://api.github.com/users/timgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/timgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timgraham/subscriptions","organizations_url":"https://api.github.com/users/timgraham/orgs","repos_url":"https://api.github.com/users/timgraham/repos","events_url":"https://api.github.com/users/timgraham/events{/privacy}","received_events_url":"https://api.github.com/users/timgraham/received_events","type":"User","site_admin":false},"body":"```\r\n``bulk_create()``\r\n```","created_at":"2016-02-10T15:58:45Z","updated_at":"2016-02-10T15:58:45Z","html_url":"https://github.com/django/django/pull/5936#discussion_r52477396","pull_request_url":"https://api.github.com/repos/django/django/pulls/5936","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/52477396"},"html":{"href":"https://github.com/django/django/pull/5936#discussion_r52477396"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/5936"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/5936","id":55212432,"html_url":"https://github.com/django/django/pull/5936","diff_url":"https://github.com/django/django/pull/5936.diff","patch_url":"https://github.com/django/django/pull/5936.patch","issue_url":"https://api.github.com/repos/django/django/issues/5936","number":5936,"state":"open","locked":false,"title":"Fixed #19527 -- Allowed QuerySet.bulk_create() to set the primary key of its objects.","user":{"login":"blablacio","id":3009538,"avatar_url":"https://avatars.githubusercontent.com/u/3009538?v=3","gravatar_id":"","url":"https://api.github.com/users/blablacio","html_url":"https://github.com/blablacio","followers_url":"https://api.github.com/users/blablacio/followers","following_url":"https://api.github.com/users/blablacio/following{/other_user}","gists_url":"https://api.github.com/users/blablacio/gists{/gist_id}","starred_url":"https://api.github.com/users/blablacio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blablacio/subscriptions","organizations_url":"https://api.github.com/users/blablacio/orgs","repos_url":"https://api.github.com/users/blablacio/repos","events_url":"https://api.github.com/users/blablacio/events{/privacy}","received_events_url":"https://api.github.com/users/blablacio/received_events","type":"User","site_admin":false},"body":"PostgreSQL supports RETURNING id when doing a bulk create. With this,\r\nwe can set the primary keys on the newly saved objects from the keys\r\nthat the database supplied.\r\n\r\nAddresses #19527\r\nRebasing #5166 to Django 1.10","created_at":"2016-01-06T13:27:22Z","updated_at":"2016-02-10T15:58:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"412cddb716c67ab84208f832c39da3a664aad931","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/5936/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/5936/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/5936/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/9156e386c6ed5e6468b6f6f4ce743e66b779f715","head":{"label":"blablacio:bulk_create_ids","ref":"bulk_create_ids","sha":"9156e386c6ed5e6468b6f6f4ce743e66b779f715","user":{"login":"blablacio","id":3009538,"avatar_url":"https://avatars.githubusercontent.com/u/3009538?v=3","gravatar_id":"","url":"https://api.github.com/users/blablacio","html_url":"https://github.com/blablacio","followers_url":"https://api.github.com/users/blablacio/followers","following_url":"https://api.github.com/users/blablacio/following{/other_user}","gists_url":"https://api.github.com/users/blablacio/gists{/gist_id}","starred_url":"https://api.github.com/users/blablacio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blablacio/subscriptions","organizations_url":"https://api.github.com/users/blablacio/orgs","repos_url":"https://api.github.com/users/blablacio/repos","events_url":"https://api.github.com/users/blablacio/events{/privacy}","received_events_url":"https://api.github.com/users/blablacio/received_events","type":"User","site_admin":false},"repo":{"id":49133306,"name":"django","full_name":"blablacio/django","owner":{"login":"blablacio","id":3009538,"avatar_url":"https://avatars.githubusercontent.com/u/3009538?v=3","gravatar_id":"","url":"https://api.github.com/users/blablacio","html_url":"https://github.com/blablacio","followers_url":"https://api.github.com/users/blablacio/followers","following_url":"https://api.github.com/users/blablacio/following{/other_user}","gists_url":"https://api.github.com/users/blablacio/gists{/gist_id}","starred_url":"https://api.github.com/users/blablacio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blablacio/subscriptions","organizations_url":"https://api.github.com/users/blablacio/orgs","repos_url":"https://api.github.com/users/blablacio/repos","events_url":"https://api.github.com/users/blablacio/events{/privacy}","received_events_url":"https://api.github.com/users/blablacio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/blablacio/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/blablacio/django","forks_url":"https://api.github.com/repos/blablacio/django/forks","keys_url":"https://api.github.com/repos/blablacio/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blablacio/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blablacio/django/teams","hooks_url":"https://api.github.com/repos/blablacio/django/hooks","issue_events_url":"https://api.github.com/repos/blablacio/django/issues/events{/number}","events_url":"https://api.github.com/repos/blablacio/django/events","assignees_url":"https://api.github.com/repos/blablacio/django/assignees{/user}","branches_url":"https://api.github.com/repos/blablacio/django/branches{/branch}","tags_url":"https://api.github.com/repos/blablacio/django/tags","blobs_url":"https://api.github.com/repos/blablacio/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blablacio/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blablacio/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/blablacio/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blablacio/django/statuses/{sha}","languages_url":"https://api.github.com/repos/blablacio/django/languages","stargazers_url":"https://api.github.com/repos/blablacio/django/stargazers","contributors_url":"https://api.github.com/repos/blablacio/django/contributors","subscribers_url":"https://api.github.com/repos/blablacio/django/subscribers","subscription_url":"https://api.github.com/repos/blablacio/django/subscription","commits_url":"https://api.github.com/repos/blablacio/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/blablacio/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/blablacio/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/blablacio/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/blablacio/django/contents/{+path}","compare_url":"https://api.github.com/repos/blablacio/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blablacio/django/merges","archive_url":"https://api.github.com/repos/blablacio/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blablacio/django/downloads","issues_url":"https://api.github.com/repos/blablacio/django/issues{/number}","pulls_url":"https://api.github.com/repos/blablacio/django/pulls{/number}","milestones_url":"https://api.github.com/repos/blablacio/django/milestones{/number}","notifications_url":"https://api.github.com/repos/blablacio/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blablacio/django/labels{/name}","releases_url":"https://api.github.com/repos/blablacio/django/releases{/id}","deployments_url":"https://api.github.com/repos/blablacio/django/deployments","created_at":"2016-01-06T12:17:30Z","updated_at":"2016-01-06T12:17:47Z","pushed_at":"2016-02-10T15:34:56Z","git_url":"git://github.com/blablacio/django.git","ssh_url":"git@github.com:blablacio/django.git","clone_url":"https://github.com/blablacio/django.git","svn_url":"https://github.com/blablacio/django","homepage":"https://www.djangoproject.com/","size":145430,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"django:master","ref":"master","sha":"f7a9872b914c8390eb1b5f5de9634160974b7d4f","user":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"repo":{"id":4164482,"name":"django","full_name":"django/django","owner":{"login":"django","id":27804,"avatar_url":"https://avatars.githubusercontent.com/u/27804?v=3","gravatar_id":"","url":"https://api.github.com/users/django","html_url":"https://github.com/django","followers_url":"https://api.github.com/users/django/followers","following_url":"https://api.github.com/users/django/following{/other_user}","gists_url":"https://api.github.com/users/django/gists{/gist_id}","starred_url":"https://api.github.com/users/django/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/django/subscriptions","organizations_url":"https://api.github.com/users/django/orgs","repos_url":"https://api.github.com/users/django/repos","events_url":"https://api.github.com/users/django/events{/privacy}","received_events_url":"https://api.github.com/users/django/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/django/django","description":"The Web framework for perfectionists with deadlines.","fork":false,"url":"https://api.github.com/repos/django/django","forks_url":"https://api.github.com/repos/django/django/forks","keys_url":"https://api.github.com/repos/django/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/django/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/django/django/teams","hooks_url":"https://api.github.com/repos/django/django/hooks","issue_events_url":"https://api.github.com/repos/django/django/issues/events{/number}","events_url":"https://api.github.com/repos/django/django/events","assignees_url":"https://api.github.com/repos/django/django/assignees{/user}","branches_url":"https://api.github.com/repos/django/django/branches{/branch}","tags_url":"https://api.github.com/repos/django/django/tags","blobs_url":"https://api.github.com/repos/django/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/django/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/django/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/django/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/django/django/statuses/{sha}","languages_url":"https://api.github.com/repos/django/django/languages","stargazers_url":"https://api.github.com/repos/django/django/stargazers","contributors_url":"https://api.github.com/repos/django/django/contributors","subscribers_url":"https://api.github.com/repos/django/django/subscribers","subscription_url":"https://api.github.com/repos/django/django/subscription","commits_url":"https://api.github.com/repos/django/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/django/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/django/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/django/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/django/django/contents/{+path}","compare_url":"https://api.github.com/repos/django/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/django/django/merges","archive_url":"https://api.github.com/repos/django/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/django/django/downloads","issues_url":"https://api.github.com/repos/django/django/issues{/number}","pulls_url":"https://api.github.com/repos/django/django/pulls{/number}","milestones_url":"https://api.github.com/repos/django/django/milestones{/number}","notifications_url":"https://api.github.com/repos/django/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/django/django/labels{/name}","releases_url":"https://api.github.com/repos/django/django/releases{/id}","deployments_url":"https://api.github.com/repos/django/django/deployments","created_at":"2012-04-28T02:47:18Z","updated_at":"2016-02-10T14:04:28Z","pushed_at":"2016-02-10T15:34:58Z","git_url":"git://github.com/django/django.git","ssh_url":"git@github.com:django/django.git","clone_url":"https://github.com/django/django.git","svn_url":"https://github.com/django/django","homepage":"https://www.djangoproject.com/","size":183178,"stargazers_count":17960,"watchers_count":17960,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7298,"mirror_url":null,"open_issues_count":102,"forks":7298,"open_issues":102,"watchers":17960,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/5936"},"html":{"href":"https://github.com/django/django/pull/5936"},"issue":{"href":"https://api.github.com/repos/django/django/issues/5936"},"comments":{"href":"https://api.github.com/repos/django/django/issues/5936/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/5936/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/5936/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/9156e386c6ed5e6468b6f6f4ce743e66b779f715"}}}}