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”.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-dictpatterns-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16257476194a69e35f909107f10a368b5e66e0e149a2de7b3a410ecbf0932d8e |
|
MD5 | f716f8635afe59e8438c60c297234e6c |
|
BLAKE2b-256 | 99f626c0ed5a170b43fde826e328447c910daf569d3927653992865fcc1e4ed9 |