Non-capturing optional URL elements in Django
问题 I'm using Django and would like to match the URLs domain.com/w and domain.com/words . I have a configuration line of the form: url(r'^w(ords)?$', 'app_name.views.view_words') view_words takes only one parameter ( request ), but it seems that Django captures the (ords) part of the regular expression and passes it to the view. When I remove (ords) from the regex and access domain.com/w , it works properly. The Django documentation and similar StackOverflow questions cover how to capture