GitHub PullRequestEvent at 2014-01-13 17:39:34
Repository: django-rest-framework
Actor: tomchristie
Payload: {"action":"closed","number":1340,"pull_request":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/1340","id":11339382,"html_url":"https://github.com/tomchristie/django-rest-framework/pull/1340","diff_url":"https://github.com/tomchristie/django-rest-framework/pull/1340.diff","patch_url":"https://github.com/tomchristie/django-rest-framework/pull/1340.patch","issue_url":"https://github.com/tomchristie/django-rest-framework/pull/1340","number":1340,"state":"closed","title":"Fix: Serializers imported before related models can cause errors","user":{"login":"dustinfarris","id":1087165,"avatar_url":"https://gravatar.com/avatar/4159a4fa55045a0b6b01ecb3b7279255?d=https%3A%2F%2Fidenticons.github.com%2F2d896b1605fb034b24afca43becca350.png&r=x","gravatar_id":"4159a4fa55045a0b6b01ecb3b7279255","url":"https://api.github.com/users/dustinfarris","html_url":"https://github.com/dustinfarris","followers_url":"https://api.github.com/users/dustinfarris/followers","following_url":"https://api.github.com/users/dustinfarris/following{/other_user}","gists_url":"https://api.github.com/users/dustinfarris/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinfarris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinfarris/subscriptions","organizations_url":"https://api.github.com/users/dustinfarris/orgs","repos_url":"https://api.github.com/users/dustinfarris/repos","events_url":"https://api.github.com/users/dustinfarris/events{/privacy}","received_events_url":"https://api.github.com/users/dustinfarris/received_events","type":"User","site_admin":false},"body":"As described in #1225, when serializers attempt to resolve related models, if the model has not yet been resolved by Django an error occurs.  This can happen if the related model is referred to by a string representation, e.g.:\r\n\r\n```python\r\n    other_model = models.ForeignKey('othermodels.OtherModel')\r\n```\r\n\r\nUsually Django resolves these long before the serializer is loaded, but edge cases exist especially in testing.  For example, a test module might import a serializer that in turn imports a models module from one app, but not from the app to which the original model has a foreign key to.  When the serializer then attempts to resolve the related models of its own model, the string representation is encountered and an `AttributeError` is thrown when the serializer attempts to access the related model's `_default_manager`.\r\n\r\n-------------------------------\r\n\r\nThis PR:\r\n\r\n* Sets up a scenario in which a serializer is initialized before certain related models are loaded and tests for a successful import of the serializer in a test module\r\n* Implements a `resolve_model` function that converts a string representation to a valid Django model using Django's own methods\r\n* Modifies the `ModelSerializer.get_default_fields` method to use `resolve_model` function when acquiring related models","created_at":"2014-01-08T21:17:46Z","updated_at":"2014-01-13T17:39:33Z","closed_at":"2014-01-13T17:39:33Z","merged_at":"2014-01-13T17:39:33Z","merge_commit_sha":"4e7d94d1ba84520412561e51cd08fce2ed975a03","assignee":null,"milestone":null,"commits_url":"https://github.com/tomchristie/django-rest-framework/pull/1340/commits","review_comments_url":"https://github.com/tomchristie/django-rest-framework/pull/1340/comments","review_comment_url":"/repos/tomchristie/django-rest-framework/pulls/comments/{number}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/1340/comments","statuses_url":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/c4d77667cf80588a2195fdc025bda53a5b977105","head":{"label":"dustinfarris:testing-nested-serializers","ref":"testing-nested-serializers","sha":"c4d77667cf80588a2195fdc025bda53a5b977105","user":{"login":"dustinfarris","id":1087165,"avatar_url":"https://gravatar.com/avatar/4159a4fa55045a0b6b01ecb3b7279255?d=https%3A%2F%2Fidenticons.github.com%2F2d896b1605fb034b24afca43becca350.png&r=x","gravatar_id":"4159a4fa55045a0b6b01ecb3b7279255","url":"https://api.github.com/users/dustinfarris","html_url":"https://github.com/dustinfarris","followers_url":"https://api.github.com/users/dustinfarris/followers","following_url":"https://api.github.com/users/dustinfarris/following{/other_user}","gists_url":"https://api.github.com/users/dustinfarris/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinfarris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinfarris/subscriptions","organizations_url":"https://api.github.com/users/dustinfarris/orgs","repos_url":"https://api.github.com/users/dustinfarris/repos","events_url":"https://api.github.com/users/dustinfarris/events{/privacy}","received_events_url":"https://api.github.com/users/dustinfarris/received_events","type":"User","site_admin":false},"repo":{"id":15746828,"name":"django-rest-framework","full_name":"dustinfarris/django-rest-framework","owner":{"login":"dustinfarris","id":1087165,"avatar_url":"https://gravatar.com/avatar/4159a4fa55045a0b6b01ecb3b7279255?d=https%3A%2F%2Fidenticons.github.com%2F2d896b1605fb034b24afca43becca350.png&r=x","gravatar_id":"4159a4fa55045a0b6b01ecb3b7279255","url":"https://api.github.com/users/dustinfarris","html_url":"https://github.com/dustinfarris","followers_url":"https://api.github.com/users/dustinfarris/followers","following_url":"https://api.github.com/users/dustinfarris/following{/other_user}","gists_url":"https://api.github.com/users/dustinfarris/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinfarris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinfarris/subscriptions","organizations_url":"https://api.github.com/users/dustinfarris/orgs","repos_url":"https://api.github.com/users/dustinfarris/repos","events_url":"https://api.github.com/users/dustinfarris/events{/privacy}","received_events_url":"https://api.github.com/users/dustinfarris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dustinfarris/django-rest-framework","description":"Awesome web-browseable Web APIs.","fork":true,"url":"https://api.github.com/repos/dustinfarris/django-rest-framework","forks_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/forks","keys_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/teams","hooks_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/hooks","issue_events_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/issues/events{/number}","events_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/events","assignees_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/assignees{/user}","branches_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/branches{/branch}","tags_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/tags","blobs_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/languages","stargazers_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/stargazers","contributors_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/contributors","subscribers_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/subscribers","subscription_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/subscription","commits_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/contents/{+path}","compare_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/merges","archive_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/downloads","issues_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/issues{/number}","pulls_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/labels{/name}","releases_url":"https://api.github.com/repos/dustinfarris/django-rest-framework/releases{/id}","created_at":"2014-01-08T20:14:46Z","updated_at":"2014-01-13T17:39:33Z","pushed_at":"2014-01-13T17:04:40Z","git_url":"git://github.com/dustinfarris/django-rest-framework.git","ssh_url":"git@github.com:dustinfarris/django-rest-framework.git","clone_url":"https://github.com/dustinfarris/django-rest-framework.git","svn_url":"https://github.com/dustinfarris/django-rest-framework","homepage":"www.django-rest-framework.org","size":10327,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","master_branch":"master"}},"base":{"label":"tomchristie:master","ref":"master","sha":"05c396cfa15138b56bf8617f4667fc41e80be104","user":{"login":"tomchristie","id":647359,"avatar_url":"https://gravatar.com/avatar/c498214bc28f28b61212169dcc372fbf?d=https%3A%2F%2Fidenticons.github.com%2Fc23fb8e0e0093a0e08cf2819c97146ba.png&r=x","gravatar_id":"c498214bc28f28b61212169dcc372fbf","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://gravatar.com/avatar/c498214bc28f28b61212169dcc372fbf?d=https%3A%2F%2Fidenticons.github.com%2Fc23fb8e0e0093a0e08cf2819c97146ba.png&r=x","gravatar_id":"c498214bc28f28b61212169dcc372fbf","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":"Awesome web-browseable Web APIs.","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":"2014-01-13T17:39:33Z","pushed_at":"2014-01-13T17:39:32Z","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":18668,"stargazers_count":1932,"watchers_count":1932,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":569,"mirror_url":null,"open_issues_count":43,"forks":569,"open_issues":43,"watchers":1932,"default_branch":"master","master_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/1340"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/1340"},"issue":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/1340"},"comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/1340/comments"},"review_comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/1340/comments"},"statuses":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/c4d77667cf80588a2195fdc025bda53a5b977105"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"tomchristie","id":647359,"avatar_url":"https://gravatar.com/avatar/c498214bc28f28b61212169dcc372fbf?d=https%3A%2F%2Fidenticons.github.com%2Fc23fb8e0e0093a0e08cf2819c97146ba.png&r=x","gravatar_id":"c498214bc28f28b61212169dcc372fbf","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},"comments":26,"review_comments":16,"commits":5,"additions":116,"deletions":2,"changed_files":13}}