{"action":"created","comment":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/23252864","id":23252864,"diff_hunk":"@@ -124,10 +135,17 @@ def _get_reverse_relationships(opts):\n     reverse_relations = OrderedDict()\n     for relation in opts.get_all_related_objects():\n         accessor_name = relation.get_accessor_name()\n+        # For < django 1.6","path":"rest_framework/utils/model_meta.py","position":40,"original_position":40,"commit_id":"6369f93d041e1879ca8ef05f0fd8fe4875fc9360","original_commit_id":"6369f93d041e1879ca8ef05f0fd8fe4875fc9360","user":{"login":"Harper04","id":31411,"avatar_url":"https://avatars.githubusercontent.com/u/31411?v=3","gravatar_id":"","url":"https://api.github.com/users/Harper04","html_url":"https://github.com/Harper04","followers_url":"https://api.github.com/users/Harper04/followers","following_url":"https://api.github.com/users/Harper04/following{/other_user}","gists_url":"https://api.github.com/users/Harper04/gists{/gist_id}","starred_url":"https://api.github.com/users/Harper04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Harper04/subscriptions","organizations_url":"https://api.github.com/users/Harper04/orgs","repos_url":"https://api.github.com/users/Harper04/repos","events_url":"https://api.github.com/users/Harper04/events{/privacy}","received_events_url":"https://api.github.com/users/Harper04/received_events","type":"User","site_admin":false},"body":"The tests where failing on Travis for django versions below 1.6 and after a quick search i couldnt find to_field there so i assumed it was introduced in Django 1.6.\r\n\r\nA little more searching shows that it was there but it is the other way around:\r\nit was named to_field and later on mutated to to_fields as an array\r\n\r\nhttps://github.com/django/django/blob/stable/1.4.x/django/db/models/fields/related.py\r\nhttps://github.com/django/django/blob/stable/1.7.x/django/db/models/fields/related.py\r\n\r\nThat makes me also concerned about defaulting to index zero\r\nCasual ForeignKeys shouldnt be a problem. They are giving a single to_field to their super class on initialization. But i found a few testcases in django related to ForeignObjects and Generics\r\nhttps://github.com/django/django/search?utf8=%E2%9C%93&q=to_fields  ","created_at":"2015-01-20T20:29:05Z","updated_at":"2015-01-20T20:29:05Z","html_url":"https://github.com/tomchristie/django-rest-framework/pull/2435#discussion_r23252864","pull_request_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435","_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/23252864"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/2435#discussion_r23252864"},"pull_request":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435"}}},"pull_request":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435","id":27613327,"html_url":"https://github.com/tomchristie/django-rest-framework/pull/2435","diff_url":"https://github.com/tomchristie/django-rest-framework/pull/2435.diff","patch_url":"https://github.com/tomchristie/django-rest-framework/pull/2435.patch","issue_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2435","number":2435,"state":"open","locked":false,"title":"Respect to_field property of ForeignKey relations","user":{"login":"Harper04","id":31411,"avatar_url":"https://avatars.githubusercontent.com/u/31411?v=3","gravatar_id":"","url":"https://api.github.com/users/Harper04","html_url":"https://github.com/Harper04","followers_url":"https://api.github.com/users/Harper04/followers","following_url":"https://api.github.com/users/Harper04/following{/other_user}","gists_url":"https://api.github.com/users/Harper04/gists{/gist_id}","starred_url":"https://api.github.com/users/Harper04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Harper04/subscriptions","organizations_url":"https://api.github.com/users/Harper04/orgs","repos_url":"https://api.github.com/users/Harper04/repos","events_url":"https://api.github.com/users/Harper04/events{/privacy}","received_events_url":"https://api.github.com/users/Harper04/received_events","type":"User","site_admin":false},"body":"Closes #2426.\r\n\r\nThis implementation just changes the Field class to SlugRelatedField and passes the to_field around (ultimately saving it to slug_field)\r\n\r\nI also added a little optimization to SlugRelatedField i have to use. I get a recursive loop for my little use case because of the validation and loading of foreign models. But i am happy to remove it.\r\n\r\nTestcases:\r\n627 passed, 1 warnings in 5.12 seconds\r\n\r\nBe gentle - it is my first contribution on github :)","created_at":"2015-01-19T15:14:44Z","updated_at":"2015-01-20T20:29:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c44410c566cac510433dcd57cd45b5471080a8f7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435/commits","review_comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435/comments","review_comment_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/{number}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2435/comments","statuses_url":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/6369f93d041e1879ca8ef05f0fd8fe4875fc9360","head":{"label":"Harper04:model-tofield-serializer","ref":"model-tofield-serializer","sha":"6369f93d041e1879ca8ef05f0fd8fe4875fc9360","user":{"login":"Harper04","id":31411,"avatar_url":"https://avatars.githubusercontent.com/u/31411?v=3","gravatar_id":"","url":"https://api.github.com/users/Harper04","html_url":"https://github.com/Harper04","followers_url":"https://api.github.com/users/Harper04/followers","following_url":"https://api.github.com/users/Harper04/following{/other_user}","gists_url":"https://api.github.com/users/Harper04/gists{/gist_id}","starred_url":"https://api.github.com/users/Harper04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Harper04/subscriptions","organizations_url":"https://api.github.com/users/Harper04/orgs","repos_url":"https://api.github.com/users/Harper04/repos","events_url":"https://api.github.com/users/Harper04/events{/privacy}","received_events_url":"https://api.github.com/users/Harper04/received_events","type":"User","site_admin":false},"repo":{"id":29463812,"name":"django-rest-framework","full_name":"Harper04/django-rest-framework","owner":{"login":"Harper04","id":31411,"avatar_url":"https://avatars.githubusercontent.com/u/31411?v=3","gravatar_id":"","url":"https://api.github.com/users/Harper04","html_url":"https://github.com/Harper04","followers_url":"https://api.github.com/users/Harper04/followers","following_url":"https://api.github.com/users/Harper04/following{/other_user}","gists_url":"https://api.github.com/users/Harper04/gists{/gist_id}","starred_url":"https://api.github.com/users/Harper04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Harper04/subscriptions","organizations_url":"https://api.github.com/users/Harper04/orgs","repos_url":"https://api.github.com/users/Harper04/repos","events_url":"https://api.github.com/users/Harper04/events{/privacy}","received_events_url":"https://api.github.com/users/Harper04/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Harper04/django-rest-framework","description":"Web APIs for Django.","fork":true,"url":"https://api.github.com/repos/Harper04/django-rest-framework","forks_url":"https://api.github.com/repos/Harper04/django-rest-framework/forks","keys_url":"https://api.github.com/repos/Harper04/django-rest-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Harper04/django-rest-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Harper04/django-rest-framework/teams","hooks_url":"https://api.github.com/repos/Harper04/django-rest-framework/hooks","issue_events_url":"https://api.github.com/repos/Harper04/django-rest-framework/issues/events{/number}","events_url":"https://api.github.com/repos/Harper04/django-rest-framework/events","assignees_url":"https://api.github.com/repos/Harper04/django-rest-framework/assignees{/user}","branches_url":"https://api.github.com/repos/Harper04/django-rest-framework/branches{/branch}","tags_url":"https://api.github.com/repos/Harper04/django-rest-framework/tags","blobs_url":"https://api.github.com/repos/Harper04/django-rest-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Harper04/django-rest-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Harper04/django-rest-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/Harper04/django-rest-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Harper04/django-rest-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/Harper04/django-rest-framework/languages","stargazers_url":"https://api.github.com/repos/Harper04/django-rest-framework/stargazers","contributors_url":"https://api.github.com/repos/Harper04/django-rest-framework/contributors","subscribers_url":"https://api.github.com/repos/Harper04/django-rest-framework/subscribers","subscription_url":"https://api.github.com/repos/Harper04/django-rest-framework/subscription","commits_url":"https://api.github.com/repos/Harper04/django-rest-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/Harper04/django-rest-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/Harper04/django-rest-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/Harper04/django-rest-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/Harper04/django-rest-framework/contents/{+path}","compare_url":"https://api.github.com/repos/Harper04/django-rest-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Harper04/django-rest-framework/merges","archive_url":"https://api.github.com/repos/Harper04/django-rest-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Harper04/django-rest-framework/downloads","issues_url":"https://api.github.com/repos/Harper04/django-rest-framework/issues{/number}","pulls_url":"https://api.github.com/repos/Harper04/django-rest-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/Harper04/django-rest-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/Harper04/django-rest-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Harper04/django-rest-framework/labels{/name}","releases_url":"https://api.github.com/repos/Harper04/django-rest-framework/releases{/id}","created_at":"2015-01-19T09:41:07Z","updated_at":"2015-01-19T16:00:36Z","pushed_at":"2015-01-19T16:00:36Z","git_url":"git://github.com/Harper04/django-rest-framework.git","ssh_url":"git@github.com:Harper04/django-rest-framework.git","clone_url":"https://github.com/Harper04/django-rest-framework.git","svn_url":"https://github.com/Harper04/django-rest-framework","homepage":"www.django-rest-framework.org","size":28912,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tomchristie:master","ref":"master","sha":"fdeef89ba79e617ea22dae68a0b42b3f60d67a4d","user":{"login":"tomchristie","id":647359,"avatar_url":"https://avatars.githubusercontent.com/u/647359?v=3","gravatar_id":"","url":"https://api.github.com/users/tomchristie","html_url":"https://github.com/tomchristie","followers_url":"https://api.github.com/users/tomchristie/followers","following_url":"https://api.github.com/users/tomchristie/following{/other_user}","gists_url":"https://api.github.com/users/tomchristie/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchristie/subscriptions","organizations_url":"https://api.github.com/users/tomchristie/orgs","repos_url":"https://api.github.com/users/tomchristie/repos","events_url":"https://api.github.com/users/tomchristie/events{/privacy}","received_events_url":"https://api.github.com/users/tomchristie/received_events","type":"User","site_admin":false},"repo":{"id":1431547,"name":"django-rest-framework","full_name":"tomchristie/django-rest-framework","owner":{"login":"tomchristie","id":647359,"avatar_url":"https://avatars.githubusercontent.com/u/647359?v=3","gravatar_id":"","url":"https://api.github.com/users/tomchristie","html_url":"https://github.com/tomchristie","followers_url":"https://api.github.com/users/tomchristie/followers","following_url":"https://api.github.com/users/tomchristie/following{/other_user}","gists_url":"https://api.github.com/users/tomchristie/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchristie/subscriptions","organizations_url":"https://api.github.com/users/tomchristie/orgs","repos_url":"https://api.github.com/users/tomchristie/repos","events_url":"https://api.github.com/users/tomchristie/events{/privacy}","received_events_url":"https://api.github.com/users/tomchristie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tomchristie/django-rest-framework","description":"Web APIs for Django.","fork":false,"url":"https://api.github.com/repos/tomchristie/django-rest-framework","forks_url":"https://api.github.com/repos/tomchristie/django-rest-framework/forks","keys_url":"https://api.github.com/repos/tomchristie/django-rest-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomchristie/django-rest-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomchristie/django-rest-framework/teams","hooks_url":"https://api.github.com/repos/tomchristie/django-rest-framework/hooks","issue_events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/events{/number}","events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/events","assignees_url":"https://api.github.com/repos/tomchristie/django-rest-framework/assignees{/user}","branches_url":"https://api.github.com/repos/tomchristie/django-rest-framework/branches{/branch}","tags_url":"https://api.github.com/repos/tomchristie/django-rest-framework/tags","blobs_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/tomchristie/django-rest-framework/languages","stargazers_url":"https://api.github.com/repos/tomchristie/django-rest-framework/stargazers","contributors_url":"https://api.github.com/repos/tomchristie/django-rest-framework/contributors","subscribers_url":"https://api.github.com/repos/tomchristie/django-rest-framework/subscribers","subscription_url":"https://api.github.com/repos/tomchristie/django-rest-framework/subscription","commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/tomchristie/django-rest-framework/contents/{+path}","compare_url":"https://api.github.com/repos/tomchristie/django-rest-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomchristie/django-rest-framework/merges","archive_url":"https://api.github.com/repos/tomchristie/django-rest-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomchristie/django-rest-framework/downloads","issues_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues{/number}","pulls_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/tomchristie/django-rest-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/tomchristie/django-rest-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomchristie/django-rest-framework/labels{/name}","releases_url":"https://api.github.com/repos/tomchristie/django-rest-framework/releases{/id}","created_at":"2011-03-02T17:13:56Z","updated_at":"2015-01-20T18:43:16Z","pushed_at":"2015-01-20T14:33:14Z","git_url":"git://github.com/tomchristie/django-rest-framework.git","ssh_url":"git@github.com:tomchristie/django-rest-framework.git","clone_url":"https://github.com/tomchristie/django-rest-framework.git","svn_url":"https://github.com/tomchristie/django-rest-framework","homepage":"www.django-rest-framework.org","size":28912,"stargazers_count":3453,"watchers_count":3453,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1048,"mirror_url":null,"open_issues_count":76,"forks":1048,"open_issues":76,"watchers":3453,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/2435"},"issue":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2435"},"comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2435/comments"},"review_comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435/comments"},"review_comment":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2435/commits"},"statuses":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/6369f93d041e1879ca8ef05f0fd8fe4875fc9360"}}}}