You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+26-24Lines changed: 26 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
-
# [Django Macros Url](https://github.com/phpdude/django-macros-url/) v0.2.0 - 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
2
2
3
-
Django Macros Url makes it easy to write (and read) url patterns in your django applications by using macros.
3
+
Django Macros URL makes it easy to write (and read) URL patterns in your Django applications by using macros.
4
4
5
-
You can combine your prefixes with macro names with underscore, for example you can use macro `:slug` and `:product_slug`. They both will be compiled to same regex pattern with their group names of course. Multiple underscores accepted too.
5
+
You can combine your prefixes with macro names with an underscore, for example, you can use a macro `:slug`
6
+
and `:product_slug`. They both will be compiled to same regex pattern with their group names of course.
If you want to offer more macros by default, you can fork and make pull request.
23
+
If you want to offer more macros by default, you can fork and make a pull request.
22
24
23
25
### Installation
24
26
25
-
You can install library with pypi like a charm.
27
+
You can install the library with PyPI.
26
28
27
29
```
28
30
pip install django-macros-url
29
31
```
30
32
31
33
### Usage
32
34
33
-
Django Macros Urls used same way as django standart urls. You just import this and declare your patterns with macros.
35
+
Django Macros URLs used the same way as Django standard URLs. You just import this and declare your
36
+
patterns with macros.
34
37
35
-
Also you can register new macro (or maybe you want to replace default macro with your like regex pattern) with `macrosurl.register(macro, pattern)` method.
38
+
Also, you can register new macro (or maybe you want to replace default macro with your like regex
39
+
pattern) with `macrosurl.register(macro, pattern)` method.
36
40
37
-
Example of registration.
41
+
An example of registration.
38
42
39
43
```python
40
44
import macrosurl
@@ -48,29 +52,30 @@ urlpatterns = patterns(
48
52
)
49
53
```
50
54
51
-
You free to register custom macro anywhere (i do it in main urls.py file). Macros Urls uses lazy initiazation. Macros will be compiled only on first request.
55
+
Feel free to register custom macro anywhere (i do it in main urls.py file). Macros URLs uses lazy
56
+
initialization. Macros will be compiled only on the first request.
52
57
53
-
### Urls normalization
58
+
### URL normalization
54
59
55
-
Once Macros Url finished compile regex pattern, it makes normalization of it by rules:
60
+
Once Macros URL completed compile regex pattern, it makes normalization of it by rules:
56
61
57
62
- Strip from left side all whitespace and ^
58
63
- Strip from right side of pattern all whitespace and $
59
64
- Add to left side ^
60
65
- Add to right side $
61
66
62
-
This makes your urls always very strong to adding any unexpected params into path.
67
+
This makes your URLs always very strong to adding any unexpected params into a path.
63
68
64
-
### Auto-calling as_view on CBV objects.
69
+
### Auto-calling as_view() on CBV objects.
65
70
66
-
Library check type of view and if view is type object with defined 'as_view' function, call this. This allow
71
+
Library check type of view and if a view is type object with defined 'as_view' function, call this. This allows
67
72
you omit ".as_view()" calls in your urls.py files. But you can call this manual with params if you need.
68
73
69
-
This feature help you to keep your urls.py files must clean as possible. I hope you like this feature!
74
+
This feature helps you to keep your urls.py files clean as possible. I hope you like this feature!
70
75
71
76
### Examples
72
77
73
-
Macro Url example urls.py file
78
+
Macros URL example urls.py file
74
79
75
80
```python
76
81
from django.conf.urls import patterns
@@ -90,7 +95,7 @@ urlpatterns = patterns(
90
95
)
91
96
```
92
97
93
-
Django way urls example
98
+
Standard Django urls example
94
99
95
100
```python
96
101
from django.conf.urls import patterns
@@ -115,14 +120,11 @@ I think you understand the difference of ways :)
115
120
116
121
#### Routing must be simple! ;-)
117
122
118
-
I think real raw url regexp patterns needed in 1% case only. Prefer simple way to write (and read, this is important) fancy clean urls.
123
+
I think raw URL regexp patterns needed in 1% case only. I prefer simple way to write (and read, this is
124
+
important) fancy clean URLs.
119
125
120
126
### Contributor
121
127
122
-
Alexandr Shurigin (aka [phpdude](https://github.com/phpdude/))
128
+
[Alexandr Shurigin](https://github.com/phpdude/)
123
129
124
-
### Additionals
125
-
126
-
Sorry for my english level :(
127
-
128
-
You are welcome fix readme to good english by pull request! Thank you.
0 commit comments