﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31809	Regex URL patterns with conditional capture break default values in view functions	Zoltán Adamek	nobody	"Hello,

When I use a conditional, named capture group in a URL pattern with a view function which has a default value, the default value is not adhered to. For a full example, this minimal Django app below will act like the following:

- On visiting /this, it will print ""this"" (as expected).
- On visiting /that, it will print ""that"" (as expected).
- On visiting / (=not specifying anything), instead of falling back to the default view parameter ""this"", I get None.


{{{
import sys

from django.conf import settings
from django.conf.urls import url 
from django.core.management import execute_from_command_line
from django.http import HttpResponse

settings.configure(
    DEBUG=True,
    ROOT_URLCONF=__name__,
)


def routing_example(request, choices=""this""):
    return HttpResponse('<html><body>{text}</body></html>'.format(text=choice))

urlpatterns = [
    url(r'^(?:(?P<choice>(this|that)))?$', routing_example),
]

if __name__ == '__main__':
    execute_from_command_line(sys.argv)

}}}
"	Uncategorized	closed	Core (URLs)	3.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
