Skip to content

Commit 4dc5756

Browse files
committed
add new url example
1 parent 66230f1 commit 4dc5756

File tree

1 file changed

+87
-8
lines changed

1 file changed

+87
-8
lines changed

content/pages/examples/django/django-conf-urls-url.markdown

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ gadgets_router.register(r'data', GadgetDataViewSet, base_name='gadgets-data')
4545

4646
urlpatterns = [
4747
~~ url(r'^backend/admin/', admin.site.urls),
48-
~~ url(r'^backend/api-auth/', include('rest_framework.urls', namespace='rest_framework')),
48+
~~ url(r'^backend/api-auth/', include('rest_framework.urls',
49+
~~ namespace='rest_framework')),
4950
~~ url(r'^backend/api-token-auth/', obtain_jwt_token),
5051
~~ url(r'^backend/api-token-refresh/', refresh_jwt_token),
5152
~~ url(r'^backend/api/v1/', include(router.urls)),
@@ -54,7 +55,79 @@ urlpatterns = [
5455
```
5556

5657

57-
## Example 2 from register
58+
## Example 2 from wagtail
59+
[wagtail](https://github.com/wagtail/wagtail)
60+
([project website](https://wagtail.io/)) is a fantastic
61+
[Django](/django.html)-based CMS with code that is open source
62+
under the
63+
[BSD 3-Clause "New" or "Revised" License](https://github.com/wagtail/wagtail/blob/master/LICENSE).
64+
65+
[**wagtail/wagtail/admin/urls/pages.py**](https://github.com/wagtail/wagtail/blob/master/wagtail/admin/urls/pages.py)
66+
67+
```python
68+
# pages.py
69+
~~from django.conf.urls import url
70+
71+
from wagtail.admin.views import page_privacy, pages
72+
73+
74+
app_name = 'wagtailadmin_pages'
75+
urlpatterns = [
76+
~~ url(r'^add/(\w+)/(\w+)/(\d+)/$', pages.create, name='add'),
77+
~~ url(r'^add/(\w+)/(\w+)/(\d+)/preview/$',
78+
~~ pages.PreviewOnCreate.as_view(), name='preview_on_add'),
79+
~~ url(r'^usage/(\w+)/(\w+)/$', pages.content_type_use,
80+
~~ name='type_use'),
81+
82+
~~ url(r'^(\d+)/edit/$', pages.edit, name='edit'),
83+
~~ url(r'^(\d+)/edit/preview/$', pages.PreviewOnEdit.as_view(),
84+
~~ name='preview_on_edit'),
85+
86+
~~ url(r'^(\d+)/view_draft/$', pages.view_draft, name='view_draft'),
87+
~~ url(r'^(\d+)/add_subpage/$', pages.add_subpage, name='add_subpage'),
88+
~~ url(r'^(\d+)/delete/$', pages.delete, name='delete'),
89+
~~ url(r'^(\d+)/unpublish/$', pages.unpublish, name='unpublish'),
90+
91+
~~ url(r'^search/$', pages.search, name='search'),
92+
93+
~~ url(r'^(\d+)/move/$', pages.move_choose_destination, name='move'),
94+
~~ url(r'^(\d+)/move/(\d+)/$', pages.move_choose_destination,
95+
~~ name='move_choose_destination'),
96+
~~ url(r'^(\d+)/move/(\d+)/confirm/$', pages.move_confirm,
97+
~~ name='move_confirm'),
98+
~~ url(r'^(\d+)/set_position/$', pages.set_page_position,
99+
~~ name='set_page_position'),
100+
101+
~~ url(r'^(\d+)/copy/$', pages.copy, name='copy'),
102+
103+
~~ url(r'^moderation/(\d+)/approve/$', pages.approve_moderation,
104+
~~ name='approve_moderation'),
105+
~~ url(r'^moderation/(\d+)/reject/$', pages.reject_moderation,
106+
~~ name='reject_moderation'),
107+
~~ url(r'^moderation/(\d+)/preview/$', pages.preview_for_moderation,
108+
~~ name='preview_for_moderation'),
109+
110+
~~ url(r'^(\d+)/privacy/$', page_privacy.set_privacy,
111+
~~ name='set_privacy'),
112+
113+
~~ url(r'^(\d+)/lock/$', pages.lock, name='lock'),
114+
~~ url(r'^(\d+)/unlock/$', pages.unlock, name='unlock'),
115+
116+
~~ url(r'^(\d+)/revisions/$', pages.revisions_index,
117+
~~ name='revisions_index'),
118+
~~ url(r'^(\d+)/revisions/(\d+)/view/$', pages.revisions_view,
119+
~~ name='revisions_view'),
120+
~~ url(r'^(\d+)/revisions/(\d+)/revert/$', pages.revisions_revert,
121+
~~ name='revisions_revert'),
122+
~~ url(r'^(\d+)/revisions/(\d+)/unschedule/$', pages.revisions_unschedule,
123+
~~ name='revisions_unschedule'),
124+
~~ url(r'^(\d+)/revisions/compare/(live|earliest|\d+)\.\.\.(live|latest|\d+)/$',
125+
~~ pages.revisions_compare, name='revisions_compare'),
126+
]
127+
```
128+
129+
130+
## Example 3 from register
58131
[register](https://github.com/ORGAN-IZE/register) is a [Django](/django.html),
59132
[Bootstrap](/bootstrap.html), [PostgreSQL](/postgresql.html) project that is
60133
open source under the
@@ -80,9 +153,11 @@ from django.contrib.auth import views
80153

81154

82155
urlpatterns = [
83-
~~ django.conf.urls.url(r'^i18n/', django.conf.urls.include('django.conf.urls.i18n')),
156+
~~ django.conf.urls.url(r'^i18n/',
157+
~~ django.conf.urls.include('django.conf.urls.i18n')),
84158
~~ django.conf.urls.url(r'^robots.txt$',
85-
~~ django.views.generic.TemplateView.as_view(template_name='robots.txt')),
159+
~~ django.views.generic.TemplateView.as_view(\
160+
~~ template_name='robots.txt')),
86161
~~ django.conf.urls.url(r'^', django.conf.urls.include('registration.urls')),
87162
~~ django.conf.urls.url(r'^brand/', django.conf.urls.include('cobrand.urls')),
88163
~~ django.conf.urls.url(r'^admin/', django.conf.urls.include(django.contrib.admin.site.urls)),
@@ -101,7 +176,7 @@ urlpatterns = [
101176
```
102177

103178

104-
## Example 3 from django-allauth
179+
## Example 4 from django-allauth
105180
[django-allauth](https://github.com/pennersr/django-allauth)
106181
([project website](https://www.intenct.nl/projects/django-allauth/)) is a
107182
[Django](/django.html) library for easily adding local and social authentication
@@ -123,7 +198,8 @@ urlpatterns = [
123198

124199
~~ url(r"^password/change/$", views.password_change,
125200
~~ name="account_change_password"),
126-
~~ url(r"^password/set/$", views.password_set, name="account_set_password"),
201+
~~ url(r"^password/set/$", views.password_set,
202+
~~ name="account_set_password"),
127203

128204
~~ url(r"^inactive/$", views.account_inactive, name="account_inactive"),
129205

@@ -142,13 +218,14 @@ urlpatterns = [
142218
~~ url(r"^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$",
143219
~~ views.password_reset_from_key,
144220
~~ name="account_reset_password_from_key"),
145-
~~ url(r"^password/reset/key/done/$", views.password_reset_from_key_done,
221+
~~ url(r"^password/reset/key/done/$",
222+
~~ views.password_reset_from_key_done,
146223
~~ name="account_reset_password_from_key_done"),
147224
]
148225
```
149226

150227

151-
## Example 4 from django-cms
228+
## Example 5 from django-cms
152229
[django-cms](https://github.com/divio/django-cms)
153230
([project website](https://www.django-cms.org/en/)) is a Python-based
154231
content management system (CMS) [library](https://pypi.org/project/django-cms/)
@@ -188,3 +265,5 @@ urlpatterns.extend([
188265
~~ url(r'^$', views.details, {'slug': ''}, name='pages-root'),
189266
])
190267
```
268+
269+

0 commit comments

Comments
 (0)