Last active
December 20, 2015 03:09
-
-
Save jneight/6061844 to your computer and use it in GitHub Desktop.
Given a uri with the form /api/v1/class/1/ get the view and args it will call from registered urls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.urlresolvers import ( | |
reverse, get_script_prefix, resolve, Resolver404) | |
prefix = get_script_prefix() | |
chomped_uri = uri | |
if prefix and chomped_uri.startswith(prefix): | |
chomped_uri = chomped_uri[len(prefix) - 1:] | |
# resolve will split cleaned uri and get PK | |
view, args, extra_venue = resolve(chomped_uri) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment