Skip to main content

Django URL alternatives provides a way for dispatching one URL pattern to the first alternative view (callback function) in a list that returns success.

Project description

django-urlalternatives - Alternative Django views under same URL pattern

Django URL alternatives provides a way for dispatching one URL pattern to the first alternative view (callback function) in a list that returns success.

version:

0.1 (or corresponding Mercurial revision hash)

web:

http://gw.tnode.com/0483-Django/

author:

GW <gw.2011@tnode.com or http://gw.tnode.com/>

license:

GPLv3+

keywords:

url alternatives, dispatcher, views, django, urlconf, same pattern

Description

In case you want to assing in an URLconf the same URL pattern to more than one view (or callback function), such that the next ones are fallbacks in case of errors (ie. HTTP response codes >= 400). This is often the case when combining different apps with dynamic URLs (such as CMSs) and you want to respond with the one that has that content.

Usage

As you can see from the following example the URL alternatives dispatcher is simply used as part of the urlpatterns variable in urls.py and supports passing of positional and keyword arguments, eg.:

urlpatterns += pattern(‘’,
(r’^’, ‘urlalternatives.views.dispatcher’, {‘callbacks’:[

app1.views.failing404, ‘app2.views.working’, (redirect_to, [], {‘url’:’/’}),

]}),

)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-urlalternatives-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

File details

Details for the file django-urlalternatives-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-urlalternatives-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b53a74fed5389abbdc3923a228d04d6f4f1ad952a7d3196863a4171ebfec1523
MD5 631527df9e00d126cd4492fe324b067d
BLAKE2b-256 09e6afa9dd9111527fe36efa7b34f95daa4f7dc82df50ad02f83c47887967fa2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page