A fork of dutils, a library for using Django urlpatterns on the clientside.
-
Add
django_js_utils
to INSTALLED_APPS -
Set the file to hold the generated urls
URLS_JS_GENERATED_FILE = 'static/js/dutils.conf.urls.js'
-
Add inclusion/exclusions patterns
URLS_INCLUDE_PREFIX = ['^api',]
URLS_INCLUDE_PATTERN = ['index','status']
URLS_EXCLUDE_PREFIX = ['^internal',]
URLS_EXCLUDE_PATTERN = ['index',]
- Add to your project:
<script type="text/javascript" src="{{STATIC_URL}}dutils.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}dutils.conf.urls.js"></script>
- Create the
URLS_JS_GENERATED_FILE
(for production remember to runcollectstatic
):
python manage.py js_urls
- Clientside Django urlpatterns:
url('time_edit', {'project_id': 1, time_id: 2}
url('time_edit', [1, 2])
Credit contributing to django-js-utils goes to:
- Marco Louro (author)
- Chris Reeves
- Dimitri Gnidash
- Luke Zapart
- Robby Dermody
- Antti Kaihola
- Simon Williams
- Jussi Vaihia