#31809: Regex URL patterns with conditional capture break default values in view
functions
-------------------------------+--------------------------------------
     Reporter:  Zoltán Adamek  |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  closed
    Component:  Core (URLs)    |                  Version:  3.0
     Severity:  Normal         |               Resolution:  invalid
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by felixxm):

 * status:  new => closed
 * resolution:   => invalid
 * component:  Uncategorized => Core (URLs)


Comment:

 This is an expected behavior because `choice` is an optional in your
 pattern, if you want to specify default parameter for you views you should
 use two patterns:
 {{{
 urlpatterns = [
     url(r'^$', routing_example),
     url(r'^(?:(?P<choice>(this|that)))?$', routing_example),
 ]
 }}}
 See [https://docs.djangoproject.com/en/3.0/topics/http/urls/#specifying-
 defaults-for-view-arguments Specifying defaults for view arguments]. Trac
 is not a support channel so if you have more question please
 TicketClosingReasons/UseSupportChannels.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31809#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.463b6c020b1b7f8fa749502908a023cd%40djangoproject.com.

Reply via email to