1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Jake Howard 98340e6858 Removed environment variable for password. Prompted now 2015-12-11 08:49:05 +00:00
django_client_reverse Added test view 2015-12-10 18:21:17 +00:00
scripts Removed environment variable for password. Prompted now 2015-12-11 08:49:05 +00:00
.gitignore Moved scripts 2015-12-10 20:43:32 +00:00
LICENSE Initial commit 2015-12-09 20:48:08 +00:00
README.md Added content to readme 2015-12-10 18:53:18 +00:00
circle.yml Dont use CI to distribute, do it manually 2015-12-10 22:52:14 +00:00
details.json trying more fixes 2015-12-10 13:32:35 +00:00
manage.py Init project, mostly from template 2015-12-09 22:02:27 +00:00
requirements.txt Added twine package 2015-12-10 20:37:12 +00:00
setup.py woops 2015-12-10 13:34:03 +00:00
testsettings.py Init project, mostly from template 2015-12-09 22:02:27 +00:00

README.md

django-client-reverse Circle CI

Django server component for accessing URL reversing on the client.

Why?

The django templating system is great, especially the URL reversing template tag. The problem is that most modern web apps have a large amount of their logic inside files outside of the templates, such as javascript files. This means that URLs can no longer be generated by reverse lookup. This is where django-client-reverse steps in!

This module allows access to the reversing functions, from the client, outside of the project template! Simply send an extra request to the URL you set up, and the reversed URL will be returned. Support for both args and kwargs!

Installation

Installation can be done using pip, eventually.

Setup

Once installed, add the package to your INSTALLED_APPS at any point after the django core apps.

INSTALLED_APPS = {
    ...
    'django-client-reverse',
    ...
}

Next, setup the URL for your endpoint in any urls.py file. Both the url regex and the namespace are not important, anything can be used.

from django_client_reverse import urls as reverse_urls
urlpatterns = [
    url(r'^reverse/$', include(reverse_urls, namespace="reverser")),
]

Thats it!

Usage

Just send a POST request to the URL you setup, and the reversed URL will be returned.

Params:

  • ident: The reverse string, using standard django syntax.
  • args (optional): arguements for the reverse.
  • kwargs (optional): Key word arguements for the reverse.

Note: If a reverse cannot be found, then status 404 is returned.