Question: Essentially I'm trying to do the opposite of what [django-ds-utils](https://github.com/Dimitri-Gnidash/django-js-utils/) does, which is get URL argument out of a resolved URL, for instance, take the following URL definition:

```
url(r'^reset_pwd/(?P<code>[A-Za-z0-9]+)/$', ResetPasswordView.as_view(), name='my.registration.views.reset_pwd'),

```

On that page, within JS, I would like to retrieve `<code>` into a kwargs array. Is this something that exists, or is there a standard approach to this?

Answer: 
AFAIK there is no standard approach. You can:

* put JS into template and render view variable
* pass variable in JS globals, setting it's value in template text
* parse window.location
...etc.

I personally prefer the second way, e.g. put this code in template and then use \_reset\_pw\_code global in javascript file:

```
<script> var _reset_pw_code = "{{ reset_code|escapejs }}" </script>

```
Recently JavaScript added a new API to do this it is currently still experimental.

```
const pattern = new URLPattern('reset_pwd/:code/', 'https://example.com');
console.log(pattern.exec('https://example.com/reset_pwd/thECode/').pathname.groups); // { code: 'thECode' }

```

<https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API>