Hi Carlton,
Thanks so much for the reply. We are temporarily migrating to re_path,
however are definitely missing the slug syntax :)
Best,
Jason
On Wednesday, August 28, 2019 at 10:15:29 PM UTC-7, Carlton Gibson wrote:
>
> Hi Jason
>
> I think in this case “just use re_path()” is the way to go. (path() being
> a convenience, rather than a replacement.)
>
> For me, complicating the signature of path() for such a corner case
> wouldn’t be a good trade-off.
>
> Kind regards,
> Carlton.
>
> On Wed, 28 Aug 2019 at 20:47, Jason Brill >
> wrote:
>
>> As re_path and url syntax utilize regex, true optional trailing slashes
>> are allowed for with the following example:
>>
>> re_path(r'^about/?$', AboutView.as_view(), name='about')
>>
>> In this example, a request to both /about and /about/ would yield a 200
>> response.
>>
>>
>>
>> Using *path* would look like this:
>>
>> path('about/', AboutView.as_view(), name='about')
>>
>> Assuming we have *APPEND_SLASH* set to true in our settings, a request
>> to 'about' would yield a redirect with a 300, and a request to 'about/'
>> would yield a 200.
>>
>>
>> Moreover, using *path* without the slash would look like this:
>>
>> path('about', AboutView.as_view(), name='about')
>>
>> Here we'd obtain a 400 when trying to access 'about/', as intended.
>>
>>
>> It is impossible to obtain the same behavior when migrating from
>> url/re_path to path. Although it is better design to not allow for two
>> valid endpoints for the same path, I believe we should support the ability
>> to easily maintain the same behavior during migrations.
>>
>> A solution may be to add a simple parameter for path, so that our route
>> declaration would look something like this:
>>
>> path('about', AboutView.as_view(), name='about', optional_slash=True)
>>
>> *or*
>>
>> path('about/', AboutView.as_view(), name='about', optional_slash=True)
>>
>>
>> Another design may be to declare a new global like
>> OPTIONAL_TRAILING_SLASH similar to APPEND_SLASH in our middleware.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-d...@googlegroups.com .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/f74a7074-a66e-4aeb-8b8a-82a845c3f84a%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/django-developers/f74a7074-a66e-4aeb-8b8a-82a845c3f84a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/6ca3f90f-eb61-4bc8-8947-46d7ad304890%40googlegroups.com.