Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A view decorator to keep url specifications in views.py

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 inlineurls
Octocat-spinner-32 .hgignore
Octocat-spinner-32 README.md
Octocat-spinner-32 setup.py
README.md

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}
Something went wrong with that request. Please try again.