1- # [ Django Macros Url] ( https://github.com/phpdude/django-macros-url/ ) v0.1.6 - Routing must be simple as possible
1+ # [ Django Macros Url] ( https://github.com/phpdude/django-macros-url/ ) v0.2.0 - Routing must be simple as possible
22
33Django Macros Url makes it easy to write (and read) url patterns in your django applications by using macros.
44
@@ -61,14 +61,21 @@ Once Macros Url finished compile regex pattern, it makes normalization of it by
6161
6262This makes your urls always very strong to adding any unexpected params into path.
6363
64+ ### Auto-calling as_view on CBV objects.
65+
66+ Library check type of view and if view is type object with defined 'as_view' function, call this. This allow
67+ you omit ".as_view()" calls in your urls.py files. But you can call this manual with params if you need.
68+
69+ This feature help you to keep your urls.py files must clean as possible. I hope you like this feature!
70+
6471### Examples
6572
6673Macro Url example urls.py file
6774
6875``` python
6976from django.conf.urls import patterns
7077from macrosurl import url
71-
78+ from project.portal.views import IndexView
7279
7380urlpatterns = patterns(
7481 ' yourapp.views' ,
@@ -79,6 +86,7 @@ urlpatterns = patterns(
7986 url(' news/:year/:month/:day' , ' news_date' ),
8087 url(' news/:slug' , ' news_entry' ),
8188 url(' ^order/:id$' , ' order' ),
89+ url(' ^$' , IndexView),
8290)
8391```
8492
@@ -87,6 +95,7 @@ Django way urls example
8795``` python
8896from django.conf.urls import patterns
8997from macrosurl import url
98+ from project.portal.views import IndexView
9099
91100
92101urlpatterns = patterns(
@@ -98,6 +107,7 @@ urlpatterns = patterns(
98107 url(' ^news/(?P<year>\d{4} >)/(?P<month>(0?([1-9])|10|11|12)>)/(?P<day>((0|1|2)?([1-9])|[1-3]0|31)>)$' , ' news_date' ),
99108 url(' ^news/(?P<slug>[\w-]+>)$' , ' news_entry' ),
100109 url(' ^order/(?P<id>\d+>)$' , ' order' ),
110+ url(' ^$' , IndexView.as_view()),
101111)
102112```
103113
0 commit comments