{"action":"created","comment":{"url":"https://api.github.com/repos/django/django/pulls/comments/26873615","id":26873615,"diff_hunk":"@@ -368,6 +368,21 @@ the following example is valid::\n In the above example, the captured ``\"username\"`` variable is passed to the\n included URLconf, as expected.\n \n+Nested captured parameters, for example ``(?P<outer>(?P<inner>\\w+))`` or\n+``((\\d+)/)?``, are discarded by Django when urls are reversed, using only the\n+outer parameters to find a reverse for a pattern. If you want to reverse such\n+patterns, only pass the outer argument or named argument.\n+\n+For cases such as making a part of the pattern optional, use non-capturing\n+arguments -- for example when a non-query page-specifier is optional::\n+\n+    # In urls.py\n+    from django.conf.urls import url\n+\n+    urlpatterns = [\n+        url(r'^(?P<username>\\w+)/(?:page-(?P<page>\\d+)/)?$', blog_entry),","path":"docs/topics/http/urls.txt","position":16,"original_position":16,"commit_id":"5e4e611abbf301cdb6b4c31f114457089bb57ae2","original_commit_id":"5e4e611abbf301cdb6b4c31f114457089bb57ae2","user":{"login":"bpeschier","id":647316,"avatar_url":"https://avatars.githubusercontent.com/u/647316?v=3","gravatar_id":"","url":"https://api.github.com/users/bpeschier","html_url":"https://github.com/bpeschier","followers_url":"https://api.github.com/users/bpeschier/followers","following_url":"https://api.github.com/users/bpeschier/following{/other_user}","gists_url":"https://api.github.com/users/bpeschier/gists{/gist_id}","starred_url":"https://api.github.com/users/bpeschier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpeschier/subscriptions","organizations_url":"https://api.github.com/users/bpeschier/orgs","repos_url":"https://api.github.com/users/bpeschier/repos","events_url":"https://api.github.com/users/bpeschier/events{/privacy}","received_events_url":"https://api.github.com/users/bpeschier/received_events","type":"User","site_admin":false},"body":"The use of nested capture parameters is not something I want to encourage by adding examples and thus adding weight to it. I have to think about the phrasing here. \r\n\r\nIf you really want to use it, you need to pass the outer parameter, but often this means you have to fabricate some part of the url -- otherwise you could just have 1 capture parameter -- and you are coupling your view pretty tightly to the url.","created_at":"2015-03-20T20:30:59Z","updated_at":"2015-03-20T20:30:59Z","html_url":"https://github.com/django/django/pull/4353#discussion_r26873615","pull_request_url":"https://api.github.com/repos/django/django/pulls/4353","_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/comments/26873615"},"html":{"href":"https://github.com/django/django/pull/4353#discussion_r26873615"},"pull_request":{"href":"https://api.github.com/repos/django/django/pulls/4353"}}},"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/4353","id":31614980,"html_url":"https://github.com/django/django/pull/4353","diff_url":"https://github.com/django/django/pull/4353.diff","patch_url":"https://github.com/django/django/pull/4353.patch","issue_url":"https://api.github.com/repos/django/django/issues/4353","number":4353,"state":"open","locked":false,"title":"Fixed #13525 -- Added tests and documentation for nested parameters.","user":{"login":"bpeschier","id":647316,"avatar_url":"https://avatars.githubusercontent.com/u/647316?v=3","gravatar_id":"","url":"https://api.github.com/users/bpeschier","html_url":"https://github.com/bpeschier","followers_url":"https://api.github.com/users/bpeschier/followers","following_url":"https://api.github.com/users/bpeschier/following{/other_user}","gists_url":"https://api.github.com/users/bpeschier/gists{/gist_id}","starred_url":"https://api.github.com/users/bpeschier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpeschier/subscriptions","organizations_url":"https://api.github.com/users/bpeschier/orgs","repos_url":"https://api.github.com/users/bpeschier/repos","events_url":"https://api.github.com/users/bpeschier/events{/privacy}","received_events_url":"https://api.github.com/users/bpeschier/received_events","type":"User","site_admin":false},"body":"When reversing, only outer parameters are used if captured parameters are\r\nnested. Added tests to check the edge cases and documentation for the\r\nbehaviour with an example to avoid it.","created_at":"2015-03-20T13:50:19Z","updated_at":"2015-03-20T20:30:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9a5422dc4cf8fc0e1b6ec62448a80ad0679e140","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/django/django/pulls/4353/commits","review_comments_url":"https://api.github.com/repos/django/django/pulls/4353/comments","review_comment_url":"https://api.github.com/repos/django/django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/django/django/issues/4353/comments","statuses_url":"https://api.github.com/repos/django/django/statuses/5e4e611abbf301cdb6b4c31f114457089bb57ae2","head":{"label":"bpeschier:ticket_13252_14772","ref":"ticket_13252_14772","sha":"5e4e611abbf301cdb6b4c31f114457089bb57ae2","user":{"login":"bpeschier","id":647316,"avatar_url":"https://avatars.githubusercontent.com/u/647316?v=3","gravatar_id":"","url":"https://api.github.com/users/bpeschier","html_url":"https://github.com/bpeschier","followers_url":"https://api.github.com/users/bpeschier/followers","following_url":"https://api.github.com/users/bpeschier/following{/other_user}","gists_url":"https://api.github.com/users/bpeschier/gists{/gist_id}","starred_url":"https://api.github.com/users/bpeschier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpeschier/subscriptions","organizations_url":"https://api.github.com/users/bpeschier/orgs","repos_url":"https://api.github.com/users/bpeschier/repos","events_url":"https://api.github.com/users/bpeschier/events{/privacy}","received_events_url":"https://api.github.com/users/bpeschier/received_events","type":"User","site_admin":false},"repo":{"id":17082465,"name":"django","full_name":"bpeschier/django","owner":{"login":"bpeschier","id":647316,"avatar_url":"https://avatars.githubusercontent.com/u/647316?v=3","gravatar_id":"","url":"https://api.github.com/users/bpeschier","html_url":"https://github.com/bpeschier","followers_url":"https://api.github.com/users/bpeschier/followers","following_url":"https://api.github.com/users/bpeschier/following{/other_user}","gists_url":"https://api.github.com/users/bpeschier/gists{/gist_id}","starred_url":"https://api.github.com/users/bpeschier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpeschier/subscriptions","organizations_url":"https://api.github.com/users/bpeschier/orgs","repos_url":"https://api.github.com/users/bpeschier/repos","events_url":"https://api.github.com/users/bpeschier/events{/privacy}","received_events_url":"https://api.github.com/users/bpeschier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bpeschier/django","description":"The Web framework for perfectionists with deadlines.","fork":true,"url":"https://api.github.com/repos/bpeschier/django","forks_url":"https://api.github.com/repos/bpeschier/django/forks","keys_url":"https://api.github.com/repos/bpeschier/django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bpeschier/django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bpeschier/django/teams","hooks_url":"https://api.github.com/repos/bpeschier/django/hooks","issue_events_url":"https://api.github.com/repos/bpeschier/django/issues/events{/number}","events_url":"https://api.github.com/repos/bpeschier/django/events","assignees_url":"https://api.github.com/repos/bpeschier/django/assignees{/user}","branches_url":"https://api.github.com/repos/bpeschier/django/branches{/branch}","tags_url":"https://api.github.com/repos/bpeschier/django/tags","blobs_url":"https://api.github.com/repos/bpeschier/django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bpeschier/django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bpeschier/django/git/refs{/sha}","trees_url":"https://api.github.com/repos/bpeschier/django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bpeschier/django/statuses/{sha}","languages_url":"https://api.github.com/repos/bpeschier/django/languages","stargazers_url":"https://api.github.com/repos/bpeschier/django/stargazers","contributors_url":"https://api.github.com/repos/bpeschier/django/contributors","subscribers_url":"https://api.github.com/repos/bpeschier/django/subscribers","subscription_url":"https://api.github.com/repos/bpeschier/django/subscription","commits_url":"https://api.github.com/repos/bpeschier/django/commits{/sha}","git_commits_url":"https://api.github.com/repos/bpeschier/django/git/commits{/sha}","comments_url":"https://api.github.com/repos/bpeschier/django/comments{/number}","issue_comment_url":"https://api.github.com/repos/bpeschier/django/issues/comments{/number}","contents_url":"https://api.github.com/repos/bpeschier/django/contents/{+path}","compare_url":"https://api.github.com/repos/bpeschier/django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bpeschier/django/merges","archive_url":"https://api.github.com/repos/bpeschier/django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bpeschier/django/downloads","issues_url":"https://api.github.com/repos/bpeschier/django/issues{/number}","pulls_url":"https://api.github.com/repos/bpeschier/django/pulls{/number}","milestones_url":"https://api.github.com/repos/bpeschier/django/milestones{/number}","notifications_url":"https://api.github.com/repos/bpeschier/django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bpeschier/django/labels{/name}","releases_url":"https://api.github.com/repos/bpeschier/django/releases{/id}","created_at":"2014-02-22T10:10:58Z","updated_at":"2015-03-20T12:24:17Z","pushed_at":"2015-03-20T18:20:20Z","git_url":"git://github.com/bpeschier/django.git","ssh_url":"git@github.com:bpeschier/django.git","clone_url":"https://github.com/bpeschier/django.git","svn_url":"https://github.com/bpeschier/django","homepage":"http://www.djangoproject.com/","size":125722,"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":"0d9b018e07c384314e142372153eb670c2e129f3","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}","created_at":"2012-04-28T02:47:18Z","updated_at":"2015-03-20T19:49:21Z","pushed_at":"2015-03-20T20:25:57Z","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":271454,"stargazers_count":13362,"watchers_count":13362,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5242,"mirror_url":null,"open_issues_count":81,"forks":5242,"open_issues":81,"watchers":13362,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/django/django/pulls/4353"},"html":{"href":"https://github.com/django/django/pull/4353"},"issue":{"href":"https://api.github.com/repos/django/django/issues/4353"},"comments":{"href":"https://api.github.com/repos/django/django/issues/4353/comments"},"review_comments":{"href":"https://api.github.com/repos/django/django/pulls/4353/comments"},"review_comment":{"href":"https://api.github.com/repos/django/django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/django/django/pulls/4353/commits"},"statuses":{"href":"https://api.github.com/repos/django/django/statuses/5e4e611abbf301cdb6b4c31f114457089bb57ae2"}}}}