#27569: Resolve reverse url with named groups regular expression to sprintf
output
formatters not specifying kwargs key / value pairs.
-------------------------------------------+-----------------------------
Reporter: Dmitriy Sintsov | Owner: nobody
Type: New feature | Status: new
Component: Core (URLs) | Version: 1.10
Severity: Normal | Keywords: reverse url
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+-----------------------------
I wrote a pluggable app which supports Django reverse url calling from
client-side Javascript (AJAX) via sprintf.js library:
https://github.com/Dmitri-Sintsov/django-jinja-
knockout/blob/e28d83886c5da0f4661257146a9925aabbcc93b8/django_jinja_knockout/static/js/front/app.js#L1276
To inject resolved reverse url with regex named parameters replaced to
sprintf output formatters, without kwargs key / value pairs supplied, I
use Python inspect module when django.django.core.urlresolvers.reverse
throws NoReverseMatch exception to get values of caller variables f_locals
keys 'prefix_norm' / '_prefix':
https://github.com/Dmitri-Sintsov/django-jinja-
knockout/blob/e28d83886c5da0f4661257146a9925aabbcc93b8/django_jinja_knockout/tpl.py#L180
Unfortunately that is a very hacky way because the urlresolvers code
changes from one Django release to another one and I am afraid that at
some point there could be new incompatibility.
Is there any cleaner way to resolve reverse url with regex named
parameters replaced to sprintf output formatters not specifying actual
kwargs key / value pairs? Because internally urlresolvers module has these
as prefix_norm / _prefix values.
Or should I try to develop a core patch? That should be useful to many
modules which route Django url names from Javascript client-side.
--
Ticket URL: <https://code.djangoproject.com/ticket/27569>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.f7470db6468947385311a5dff364c6bb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.