Skip to content

tghw/django-inlineurls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Django Inline Urls

django-inlineurls defines a decorator, view(), which define what URL a view will be accessible by. It also has options for what template to render, whether the view requires login, and any other url kwargs.

If a template is specified, you can simply return a context for it to be rendered with.

Use

# views.py
from inlineurls.decorators import view

@view('/search/(?P<query>[^/]+/') # A view with no template
def search(request, query):
    return render(request, 'search.html', {'query': query})

@view('/home/', 'home.html') # A view with a template defined. Note only the context is returned
def home(request):
    return {'date': now()}

@view('/dashboard/', 'dashboard.html', True) # A login_required view
def home(request):
    return {'user': request.user}

About

A view decorator to keep url specifications in views.py

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages