Skip to content

Instantly share code, notes, and snippets.

@Suor
Created April 27, 2017 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suor/22f162549fb634e3c3adea518c080eb7 to your computer and use it in GitHub Desktop.
Save Suor/22f162549fb634e3c3adea518c080eb7 to your computer and use it in GitHub Desktop.
Django local urls
from localurls import Router
router = Router()
snapshot = router.url('/snapshot/', method='POST')
@snapshot.add(query={'action': 'make'})
def snapshot_make(request):
pass
@snapshot.add(query={'action': 'add'})
def snapshot_add(request):
pass
# snapshot_router = router.url('/snapshot/', method='POST').add
# @snapshot_router.add(query={'action': 'make'})
# def snapshot(request):
# pass
@router.add('/snapshot/', method='POST', query=lambda m: {'action': m.__name__})
class Snapshot:
def make(request):
pass
def add(request):
pass
@router.add(lambda m: '/snapshot/%s/' % m.__name__)
class Snapshot:
def make(request):
pass
def add(request):
pass
@router.nest('/snapshot/')
class Snapshot:
def make(request):
pass
def add(request):
pass
# sub='url' (default), sub=method (GET/POST/...), sub=POST.<field> / GET.<field> / REQUEST.<field>
@router.add('/snapshot/', method='POST', sub='POST.action')
class Snapshot:
def make(request):
pass
def add(request):
pass
snapshot = router.nest('/snapshot/', method='POST', sub='POST.action')
@snapshot.add
def make(request):
pass
@snapshot.add
def add(request):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment