Skip to content

Instantly share code, notes, and snippets.

@d7my11
Created May 21, 2015 13:14
Show Gist options
  • Save d7my11/160708a9507c4cbcbdcd to your computer and use it in GitHub Desktop.
Save d7my11/160708a9507c4cbcbdcd to your computer and use it in GitHub Desktop.
def add_url(self, endpoint):
"""Adds additional urls to the resource
:endpoint: the end point API to be added
:returns: the url created ( for tastypie )
"""
api = r'(?P<resource_name>%s)/(?P<endpoint>%s)%s$' % (
self._meta.resource_name, endpoint, trailing_slash())
endpoint = endpoint.replace('/', '_')
return url(api, self.wrap_view(endpoint), name='api_%s' % endpoint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment