That's also already done, check
https://github.com/django-extensions/django-extensions/blob/master/django_extensions/management/commands/show_urls.py,
it can be easily converted to JSON (I have a branch that does it, but
it's not up-to-date).

I also have the urls module in JavaScript already, but as part of a
larger library (https://github.com/mlouro/olivejs/blob/master/olive/
urls/urls.js), both have been used in projects.

An example:

/* below is the output from "manage.py show_urls" in JSON format */
olive.urls.load({
     'dashboard': '/dashboard/',
     'time_edit': '/projects/<project_id>/time/save/<time_id>/',
     'task_edit': '/projects/<project_id>/task/save/<task_id>/'
});

olive.urls.get('task_edit', {
         'project_id': 2,
         'task_id': 1
     })


This all sounds pretty cool - I'd love to be able to reverse URLs in JavaScript. Keep in mind, though, that URLConfs can change on a per-request basis, by setting request.urlconf. Any JSON data structure representing the URLConf would need to be generated after this has been set (ie. some time after request middleware has been processed, look at django.core.handlers.base:94-98). Having a template tag would probably be fine, as the URLConf is set by render time, but don't expect to be able to do a one-off analysis of the URLConf at application startup.

Cheers,
Dan

--
Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com

--
You received this message because you are subscribed to the Google Groups "Django 
developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to