django-url-namespaces 0.1.0

Declarative class-based datastructures, for simple and flexible URLConfs in Django.

This is a somewhat-functional attempt to bring a more intuitive and less spaghettified syntax to Django's URLConf. It implements a declarative class-based syntax:

    # (née 'URLConf')

    from django.conf.urls import patterns
    from url_namespaces import (Namespace, View, Redirect, \
                                ReverseRedirect, KeywordReverseRedirect)

    class MyOtherURLs(Namespace):
        """ URL namespaces are classes, 
            the URLs they contain are properties
            of those classes. """
        class Meta:
            namespace = 'testapp:views'
            app_name = 'testapp'
            view_prefix = ''
        rss = View(
                arg='yo', other_arg='dogg')
        index = View(
        entry = View(
    class MyURLs(Namespace):
        """ Namespaces can be nested """
        class Meta:
            namespace = 'testapp'
            app_name = 'testapp'
            view_prefix = ''
        pages = MyOtherURLs(r'^/pages/')
        elsewhere = Redirect(
        root = ReverseRedirect(
                'testapp:index', blog="test")
        entry_redirect = ReverseRedirect(
                'testapp:entry', blog="%(blog)s", entry="%(entry)s")
        entry_redirect_again = KeywordReverseRedirect(

    # These classes generate standard URL patterns
    # and use url(), reverse(), RegexURLResolver;
    # the project aims for compatibility with Django's
    # URLConf structures. 
    urlpatterns = patterns('',

Djano-URL-Namespaces implements a host of combinator objects, representing intuitive ideas e.g. `View`, `Redirect`, `Namespace` &c,
which can be modularly rearranged without the worries incumbent in getting ones' hands dirty with the rather fragile Django-native
URLConf syntax.

At the time of writing the project is in a state of somewhat indeterminate disrepair; namespaces don't nest quite right, there's a lot of sketchy code commented out and not enough docstrings, etc. If this is the sort of thing that floats your boat, know that I never turn away an entertaining pull-request, indeed!


Alexander Bohn




  • Development Status :: 5 - Production/Stable
  • License :: OSI Approved :: MIT License
  • Operating System :: OS Independent
  • Programming Language :: Python :: 2.6
  • Operating System :: Microsoft :: Windows
  • Operating System :: POSIX
  • Operating System :: Unix
  • Operating System :: MacOS
File Type Python Version Uploaded On Downloads
django-url-namespaces-0.1.0.tar.gz Source Oct. 2, 2012 2,254
Version Release Date
0.1.0 Oct. 2, 2012
Date Package Version Action
Aug. 26, 2015, 12:30 a.m. django-url-namespaces 0.1.0 Release Created
Aug. 26, 2015, 12:30 a.m. django-url-namespaces Package Created