{"action":"created","comment":{"url":"https://api.github.com/repos/etalab/udata/pulls/comments/34897354","id":34897354,"diff_hunk":"@@ -46,7 +46,12 @@ def get(self, id):\n     @api.doc(id='follow', description=NOTE)\n     def post(self, id):\n         '''Follow an object given its ID'''\n-        follow, created = self.model.objects.get_or_create(follower=current_user.id, following=id, until=None)\n+        try:\n+            follow = self.model.objects.get(follower=current_user.id, following=id, until=None)\n+            created = False\n+        except self.model.DoesNotExist:\n+            follow = self.model.objects.create(follower=current_user.id, following=id, until=None)\n+            created = True","path":"udata/core/followers/api.py","position":10,"original_position":10,"commit_id":"1c3533dff67d3d94c29239952f9e076f0402c66b","original_commit_id":"1c3533dff67d3d94c29239952f9e076f0402c66b","user":{"login":"noirbizarre","id":15725,"avatar_url":"https://avatars.githubusercontent.com/u/15725?v=3","gravatar_id":"","url":"https://api.github.com/users/noirbizarre","html_url":"https://github.com/noirbizarre","followers_url":"https://api.github.com/users/noirbizarre/followers","following_url":"https://api.github.com/users/noirbizarre/following{/other_user}","gists_url":"https://api.github.com/users/noirbizarre/gists{/gist_id}","starred_url":"https://api.github.com/users/noirbizarre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noirbizarre/subscriptions","organizations_url":"https://api.github.com/users/noirbizarre/orgs","repos_url":"https://api.github.com/users/noirbizarre/repos","events_url":"https://api.github.com/users/noirbizarre/events{/privacy}","received_events_url":"https://api.github.com/users/noirbizarre/received_events","type":"User","site_admin":false},"body":"Do we make it a reusable get_or_create here:\r\nhttps://github.com/etalab/udata/blob/master/udata/models/__init__.py#L84-L91","created_at":"2015-07-17T15:01:08Z","updated_at":"2015-07-17T15:01:08Z","html_url":"https://github.com/etalab/udata/pull/107#discussion_r34897354","pull_request_url":"https://api.github.com/repos/etalab/udata/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/etalab/udata/pulls/comments/34897354"},"html":{"href":"https://github.com/etalab/udata/pull/107#discussion_r34897354"},"pull_request":{"href":"https://api.github.com/repos/etalab/udata/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/etalab/udata/pulls/107","id":40238450,"html_url":"https://github.com/etalab/udata/pull/107","diff_url":"https://github.com/etalab/udata/pull/107.diff","patch_url":"https://github.com/etalab/udata/pull/107.patch","issue_url":"https://api.github.com/repos/etalab/udata/issues/107","number":107,"state":"open","locked":false,"title":"Update mongoengine to 0.10.0 and pymongo to 3.0.3","user":{"login":"davidbgk","id":3556,"avatar_url":"https://avatars.githubusercontent.com/u/3556?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbgk","html_url":"https://github.com/davidbgk","followers_url":"https://api.github.com/users/davidbgk/followers","following_url":"https://api.github.com/users/davidbgk/following{/other_user}","gists_url":"https://api.github.com/users/davidbgk/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbgk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbgk/subscriptions","organizations_url":"https://api.github.com/users/davidbgk/orgs","repos_url":"https://api.github.com/users/davidbgk/repos","events_url":"https://api.github.com/users/davidbgk/events{/privacy}","received_events_url":"https://api.github.com/users/davidbgk/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-17T14:49:37Z","updated_at":"2015-07-17T15:01:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"090d07cc2de60c08bff097afc7800985d7b4c04e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/etalab/udata/pulls/107/commits","review_comments_url":"https://api.github.com/repos/etalab/udata/pulls/107/comments","review_comment_url":"https://api.github.com/repos/etalab/udata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/etalab/udata/issues/107/comments","statuses_url":"https://api.github.com/repos/etalab/udata/statuses/1c3533dff67d3d94c29239952f9e076f0402c66b","head":{"label":"davidbgk:106-update-mongo","ref":"106-update-mongo","sha":"1c3533dff67d3d94c29239952f9e076f0402c66b","user":{"login":"davidbgk","id":3556,"avatar_url":"https://avatars.githubusercontent.com/u/3556?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbgk","html_url":"https://github.com/davidbgk","followers_url":"https://api.github.com/users/davidbgk/followers","following_url":"https://api.github.com/users/davidbgk/following{/other_user}","gists_url":"https://api.github.com/users/davidbgk/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbgk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbgk/subscriptions","organizations_url":"https://api.github.com/users/davidbgk/orgs","repos_url":"https://api.github.com/users/davidbgk/repos","events_url":"https://api.github.com/users/davidbgk/events{/privacy}","received_events_url":"https://api.github.com/users/davidbgk/received_events","type":"User","site_admin":false},"repo":{"id":33595552,"name":"udata","full_name":"davidbgk/udata","owner":{"login":"davidbgk","id":3556,"avatar_url":"https://avatars.githubusercontent.com/u/3556?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbgk","html_url":"https://github.com/davidbgk","followers_url":"https://api.github.com/users/davidbgk/followers","following_url":"https://api.github.com/users/davidbgk/following{/other_user}","gists_url":"https://api.github.com/users/davidbgk/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbgk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbgk/subscriptions","organizations_url":"https://api.github.com/users/davidbgk/orgs","repos_url":"https://api.github.com/users/davidbgk/repos","events_url":"https://api.github.com/users/davidbgk/events{/privacy}","received_events_url":"https://api.github.com/users/davidbgk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davidbgk/udata","description":"Social data platform","fork":true,"url":"https://api.github.com/repos/davidbgk/udata","forks_url":"https://api.github.com/repos/davidbgk/udata/forks","keys_url":"https://api.github.com/repos/davidbgk/udata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidbgk/udata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidbgk/udata/teams","hooks_url":"https://api.github.com/repos/davidbgk/udata/hooks","issue_events_url":"https://api.github.com/repos/davidbgk/udata/issues/events{/number}","events_url":"https://api.github.com/repos/davidbgk/udata/events","assignees_url":"https://api.github.com/repos/davidbgk/udata/assignees{/user}","branches_url":"https://api.github.com/repos/davidbgk/udata/branches{/branch}","tags_url":"https://api.github.com/repos/davidbgk/udata/tags","blobs_url":"https://api.github.com/repos/davidbgk/udata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidbgk/udata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidbgk/udata/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidbgk/udata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidbgk/udata/statuses/{sha}","languages_url":"https://api.github.com/repos/davidbgk/udata/languages","stargazers_url":"https://api.github.com/repos/davidbgk/udata/stargazers","contributors_url":"https://api.github.com/repos/davidbgk/udata/contributors","subscribers_url":"https://api.github.com/repos/davidbgk/udata/subscribers","subscription_url":"https://api.github.com/repos/davidbgk/udata/subscription","commits_url":"https://api.github.com/repos/davidbgk/udata/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidbgk/udata/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidbgk/udata/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidbgk/udata/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidbgk/udata/contents/{+path}","compare_url":"https://api.github.com/repos/davidbgk/udata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidbgk/udata/merges","archive_url":"https://api.github.com/repos/davidbgk/udata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidbgk/udata/downloads","issues_url":"https://api.github.com/repos/davidbgk/udata/issues{/number}","pulls_url":"https://api.github.com/repos/davidbgk/udata/pulls{/number}","milestones_url":"https://api.github.com/repos/davidbgk/udata/milestones{/number}","notifications_url":"https://api.github.com/repos/davidbgk/udata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidbgk/udata/labels{/name}","releases_url":"https://api.github.com/repos/davidbgk/udata/releases{/id}","created_at":"2015-04-08T08:51:08Z","updated_at":"2015-05-07T13:55:38Z","pushed_at":"2015-07-17T14:49:21Z","git_url":"git://github.com/davidbgk/udata.git","ssh_url":"git@github.com:davidbgk/udata.git","clone_url":"https://github.com/davidbgk/udata.git","svn_url":"https://github.com/davidbgk/udata","homepage":null,"size":3489,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"etalab:master","ref":"master","sha":"8ac03198c71c18bb58611d252b52572d37e39fcc","user":{"login":"etalab","id":5313610,"avatar_url":"https://avatars.githubusercontent.com/u/5313610?v=3","gravatar_id":"","url":"https://api.github.com/users/etalab","html_url":"https://github.com/etalab","followers_url":"https://api.github.com/users/etalab/followers","following_url":"https://api.github.com/users/etalab/following{/other_user}","gists_url":"https://api.github.com/users/etalab/gists{/gist_id}","starred_url":"https://api.github.com/users/etalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etalab/subscriptions","organizations_url":"https://api.github.com/users/etalab/orgs","repos_url":"https://api.github.com/users/etalab/repos","events_url":"https://api.github.com/users/etalab/events{/privacy}","received_events_url":"https://api.github.com/users/etalab/received_events","type":"Organization","site_admin":false},"repo":{"id":19141754,"name":"udata","full_name":"etalab/udata","owner":{"login":"etalab","id":5313610,"avatar_url":"https://avatars.githubusercontent.com/u/5313610?v=3","gravatar_id":"","url":"https://api.github.com/users/etalab","html_url":"https://github.com/etalab","followers_url":"https://api.github.com/users/etalab/followers","following_url":"https://api.github.com/users/etalab/following{/other_user}","gists_url":"https://api.github.com/users/etalab/gists{/gist_id}","starred_url":"https://api.github.com/users/etalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etalab/subscriptions","organizations_url":"https://api.github.com/users/etalab/orgs","repos_url":"https://api.github.com/users/etalab/repos","events_url":"https://api.github.com/users/etalab/events{/privacy}","received_events_url":"https://api.github.com/users/etalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/etalab/udata","description":"Social data platform","fork":false,"url":"https://api.github.com/repos/etalab/udata","forks_url":"https://api.github.com/repos/etalab/udata/forks","keys_url":"https://api.github.com/repos/etalab/udata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/etalab/udata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/etalab/udata/teams","hooks_url":"https://api.github.com/repos/etalab/udata/hooks","issue_events_url":"https://api.github.com/repos/etalab/udata/issues/events{/number}","events_url":"https://api.github.com/repos/etalab/udata/events","assignees_url":"https://api.github.com/repos/etalab/udata/assignees{/user}","branches_url":"https://api.github.com/repos/etalab/udata/branches{/branch}","tags_url":"https://api.github.com/repos/etalab/udata/tags","blobs_url":"https://api.github.com/repos/etalab/udata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/etalab/udata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/etalab/udata/git/refs{/sha}","trees_url":"https://api.github.com/repos/etalab/udata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/etalab/udata/statuses/{sha}","languages_url":"https://api.github.com/repos/etalab/udata/languages","stargazers_url":"https://api.github.com/repos/etalab/udata/stargazers","contributors_url":"https://api.github.com/repos/etalab/udata/contributors","subscribers_url":"https://api.github.com/repos/etalab/udata/subscribers","subscription_url":"https://api.github.com/repos/etalab/udata/subscription","commits_url":"https://api.github.com/repos/etalab/udata/commits{/sha}","git_commits_url":"https://api.github.com/repos/etalab/udata/git/commits{/sha}","comments_url":"https://api.github.com/repos/etalab/udata/comments{/number}","issue_comment_url":"https://api.github.com/repos/etalab/udata/issues/comments{/number}","contents_url":"https://api.github.com/repos/etalab/udata/contents/{+path}","compare_url":"https://api.github.com/repos/etalab/udata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/etalab/udata/merges","archive_url":"https://api.github.com/repos/etalab/udata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/etalab/udata/downloads","issues_url":"https://api.github.com/repos/etalab/udata/issues{/number}","pulls_url":"https://api.github.com/repos/etalab/udata/pulls{/number}","milestones_url":"https://api.github.com/repos/etalab/udata/milestones{/number}","notifications_url":"https://api.github.com/repos/etalab/udata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/etalab/udata/labels{/name}","releases_url":"https://api.github.com/repos/etalab/udata/releases{/id}","created_at":"2014-04-25T09:57:34Z","updated_at":"2015-07-14T02:00:54Z","pushed_at":"2015-07-17T14:49:37Z","git_url":"git://github.com/etalab/udata.git","ssh_url":"git@github.com:etalab/udata.git","clone_url":"https://github.com/etalab/udata.git","svn_url":"https://github.com/etalab/udata","homepage":null,"size":4488,"stargazers_count":11,"watchers_count":11,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":15,"forks":5,"open_issues":15,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/etalab/udata/pulls/107"},"html":{"href":"https://github.com/etalab/udata/pull/107"},"issue":{"href":"https://api.github.com/repos/etalab/udata/issues/107"},"comments":{"href":"https://api.github.com/repos/etalab/udata/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/etalab/udata/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/etalab/udata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/etalab/udata/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/etalab/udata/statuses/1c3533dff67d3d94c29239952f9e076f0402c66b"}}}}