skip to navigation
skip to content

Not Logged In

django-dictpatterns 0.2.1

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

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”.

 
File Type Py Version Uploaded on Size
django-dictpatterns-0.2.1.tar.gz (md5) Source 2014-04-06 3KB
  • Downloads (All Versions):
  • 1 downloads in the last day
  • 27 downloads in the last week
  • 167 downloads in the last month