{"action":"created","comment":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/26927409","id":26927409,"diff_hunk":"@@ -653,6 +654,30 @@ def to_representation(self, value):\n         return str(value)\n \n \n+class IPAddressField(CharField):\n+    \"\"\"Support both IPAddressField and GenericIPAddressField\"\"\"\n+\n+    default_error_messages = {\n+        'invalid': _('Enter a valid IPv4 or IPv6 address.'),\n+    }\n+\n+    def __init__(self, protocol='both', unpack_ipv4=False, **kwargs):\n+        self.protocol = protocol\n+        self.unpack_ipv4 = unpack_ipv4\n+        super(IPAddressField, self).__init__(**kwargs)\n+        validators, error_message = ip_address_validators(protocol, unpack_ipv4)\n+        self.validators.extend(validators)\n+\n+    def to_internal_value(self, data):\n+        if data and ':' in data:\n+            try:\n+                return clean_ipv6_address(data, self.unpack_ipv4)\n+            except DjangoValidationError:\n+                self.fail('invalid', value=data)","path":"rest_framework/fields.py","position":38,"original_position":38,"commit_id":"a0049dd4897577950c3804163aa501d1d08cd369","original_commit_id":"a0049dd4897577950c3804163aa501d1d08cd369","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},"body":"Looking good. I think we arrived at a slight tweak to this, that involved us getting rid of the `unpack_ipv4` flag and just always having that as True for `'both'`. Something like this?...\r\n\r\n    if self.protocol in ('both', 'ipv6'):\r\n        unpack_ipv4 = (self.protocol == 'both')\r\n        return clean_ipv6_address(data)\r\n    return data","created_at":"2015-03-23T10:59:06Z","updated_at":"2015-03-23T10:59:06Z","html_url":"https://github.com/tomchristie/django-rest-framework/pull/2747#discussion_r26927409","pull_request_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747","_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/26927409"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/2747#discussion_r26927409"},"pull_request":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747"}}},"pull_request":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747","id":31696925,"html_url":"https://github.com/tomchristie/django-rest-framework/pull/2747","diff_url":"https://github.com/tomchristie/django-rest-framework/pull/2747.diff","patch_url":"https://github.com/tomchristie/django-rest-framework/pull/2747.patch","issue_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2747","number":2747,"state":"open","locked":false,"title":"IPAddressField and tests imporvements","user":{"login":"andreagrandi","id":636391,"avatar_url":"https://avatars.githubusercontent.com/u/636391?v=3","gravatar_id":"","url":"https://api.github.com/users/andreagrandi","html_url":"https://github.com/andreagrandi","followers_url":"https://api.github.com/users/andreagrandi/followers","following_url":"https://api.github.com/users/andreagrandi/following{/other_user}","gists_url":"https://api.github.com/users/andreagrandi/gists{/gist_id}","starred_url":"https://api.github.com/users/andreagrandi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreagrandi/subscriptions","organizations_url":"https://api.github.com/users/andreagrandi/orgs","repos_url":"https://api.github.com/users/andreagrandi/repos","events_url":"https://api.github.com/users/andreagrandi/events{/privacy}","received_events_url":"https://api.github.com/users/andreagrandi/received_events","type":"User","site_admin":false},"body":"This PR is an extension of this original one https://github.com/tomchristie/django-rest-framework/pull/2618\r\n\r\nWhat I did was reviewing the code and adding a couple of test cases to the IPAddressField.\r\n\r\nThis code was produced as part of the Django Sprint hosted by Potato in London: http://djangosprint.london/","created_at":"2015-03-22T22:54:37Z","updated_at":"2015-03-23T10:59:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32f3d53039d665efe642304abe6c907a20eace8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747/commits","review_comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747/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/2747/comments","statuses_url":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/a0049dd4897577950c3804163aa501d1d08cd369","head":{"label":"andreagrandi:feature/ipaddress-fix","ref":"feature/ipaddress-fix","sha":"a0049dd4897577950c3804163aa501d1d08cd369","user":{"login":"andreagrandi","id":636391,"avatar_url":"https://avatars.githubusercontent.com/u/636391?v=3","gravatar_id":"","url":"https://api.github.com/users/andreagrandi","html_url":"https://github.com/andreagrandi","followers_url":"https://api.github.com/users/andreagrandi/followers","following_url":"https://api.github.com/users/andreagrandi/following{/other_user}","gists_url":"https://api.github.com/users/andreagrandi/gists{/gist_id}","starred_url":"https://api.github.com/users/andreagrandi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreagrandi/subscriptions","organizations_url":"https://api.github.com/users/andreagrandi/orgs","repos_url":"https://api.github.com/users/andreagrandi/repos","events_url":"https://api.github.com/users/andreagrandi/events{/privacy}","received_events_url":"https://api.github.com/users/andreagrandi/received_events","type":"User","site_admin":false},"repo":{"id":32677896,"name":"django-rest-framework","full_name":"andreagrandi/django-rest-framework","owner":{"login":"andreagrandi","id":636391,"avatar_url":"https://avatars.githubusercontent.com/u/636391?v=3","gravatar_id":"","url":"https://api.github.com/users/andreagrandi","html_url":"https://github.com/andreagrandi","followers_url":"https://api.github.com/users/andreagrandi/followers","following_url":"https://api.github.com/users/andreagrandi/following{/other_user}","gists_url":"https://api.github.com/users/andreagrandi/gists{/gist_id}","starred_url":"https://api.github.com/users/andreagrandi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreagrandi/subscriptions","organizations_url":"https://api.github.com/users/andreagrandi/orgs","repos_url":"https://api.github.com/users/andreagrandi/repos","events_url":"https://api.github.com/users/andreagrandi/events{/privacy}","received_events_url":"https://api.github.com/users/andreagrandi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andreagrandi/django-rest-framework","description":"Web APIs for Django.","fork":true,"url":"https://api.github.com/repos/andreagrandi/django-rest-framework","forks_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/forks","keys_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/teams","hooks_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/hooks","issue_events_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/issues/events{/number}","events_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/events","assignees_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/assignees{/user}","branches_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/branches{/branch}","tags_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/tags","blobs_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/languages","stargazers_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/stargazers","contributors_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/contributors","subscribers_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/subscribers","subscription_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/subscription","commits_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/issues/comments{/number}","contents_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/contents/{+path}","compare_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/merges","archive_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/downloads","issues_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/issues{/number}","pulls_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/labels{/name}","releases_url":"https://api.github.com/repos/andreagrandi/django-rest-framework/releases{/id}","created_at":"2015-03-22T14:02:02Z","updated_at":"2015-03-22T14:02:04Z","pushed_at":"2015-03-22T23:21:14Z","git_url":"git://github.com/andreagrandi/django-rest-framework.git","ssh_url":"git@github.com:andreagrandi/django-rest-framework.git","clone_url":"https://github.com/andreagrandi/django-rest-framework.git","svn_url":"https://github.com/andreagrandi/django-rest-framework","homepage":"www.django-rest-framework.org","size":16552,"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":"c9618cc0f33bec0e14c814e778727c084410badb","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-03-23T10:28:28Z","pushed_at":"2015-03-23T10:20:20Z","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":33278,"stargazers_count":3761,"watchers_count":3761,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1161,"mirror_url":null,"open_issues_count":106,"forks":1161,"open_issues":106,"watchers":3761,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/2747"},"issue":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2747"},"comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2747/comments"},"review_comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2747/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/2747/commits"},"statuses":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/a0049dd4897577950c3804163aa501d1d08cd369"}}}}