Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

This makes your application be able to write simple urlpatterns with dictionary for Django

Project Description

In urls.py, you can write urlpatterns by using dictionary.

from django.conf.urls import include
from django.contrib import admin
admin.autodiscover()

from dictpatterns.urls import DictPatterns

UrlDictPatterns = DictPatterns(
    {
        r'^': ('testapp.views.home', 'home',
            {
                r'test/': ('testapp.views.test', 'test',
                    {
                        r'(?P<id>\d*)/': ('testapp.views.test_n', 'test_n',
                            {
                                r'd/': ('testapp.views.test_d', 'test_d')
                            }
                        )
                    }
                ),
                r'admin/': (include(admin.site.urls), 'admin')
            }
        )
    }
)

urlpatterns = UrlDictPatterns.to_patterns()

In template

Because of this format, you can trace the parent url of a page. You can display the parent url in template.

{% load dict_url_tools %}

Now :
<br>
{% this_url %}
<br>
Parent :
<br>
{% parent_url %}

Settings

Make sure of writing DictPatterns in your urls which is designated as ROOT_URLCONF. And designate the root of DictPatterns as ROOT_DICTPATTERNS_NAME in settings.py if you need. Default value is “UrlDictPatterns”.

Release History

Release History

This version
History Node

0.2.1

History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-dictpatterns-0.2.1.tar.gz (3.4 kB) Copy SHA256 Checksum SHA256 Source Apr 6, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting