Skip to content

Commit 9cb93ee

Browse files
author
Jaap Roes
authored
Simplify how urlpatterns are loaded (#1436)
1 parent 924310b commit 9cb93ee

File tree

7 files changed

+15
-7
lines changed

7 files changed

+15
-7
lines changed

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Hiroki Kiyohara
6262
Hossein Shakiba
6363
Islam Kamel
6464
Ivan Lukyanets
65+
Jaap Roes
6566
Jadiel Teófilo
6667
Jens Timmerman
6768
Jerome Leclanche

Diff for: README.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ Add ``oauth2_provider`` to your ``INSTALLED_APPS``
6565
6666
6767
If you need an OAuth2 provider you'll want to add the following to your ``urls.py``.
68-
Notice that ``oauth2_provider`` namespace is mandatory.
6968

7069
.. code-block:: python
7170
71+
from oauth2_provider import urls as oauth2_urls
72+
7273
urlpatterns = [
7374
...
74-
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
75+
path('o/', include(oauth2_urls)),
7576
]
7677
7778
Changelog

Diff for: docs/getting_started.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ Include ``oauth2_provider.urls`` to :file:`iam/urls.py` as follows:
191191
192192
from django.contrib import admin
193193
from django.urls import include, path
194+
from oauth2_provider import urls as oauth2_urls
194195
195196
urlpatterns = [
196197
path('admin/', admin.site.urls),
197-
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
198+
path('o/', include(oauth2_urls)),
198199
]
199200
200201
This will make available endpoints to authorize, generate token and create OAuth applications.

Diff for: docs/install.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ If you need an OAuth2 provider you'll want to add the following to your :file:`u
2020
.. code-block:: python
2121
2222
from django.urls import include, path
23+
from oauth2_provider import urls as oauth2_urls
2324
2425
urlpatterns = [
2526
...
26-
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
27+
path('o/', include(oauth2_urls),
2728
]
2829
2930
Sync your database

Diff for: docs/rest-framework/getting_started.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Here's our project's root :file:`urls.py` module:
5151
5252
from rest_framework import generics, permissions, serializers
5353
54+
from oauth2_provider import urls as oauth2_urls
5455
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope, TokenHasScope
5556
5657
# first we define the serializers
@@ -84,7 +85,7 @@ Here's our project's root :file:`urls.py` module:
8485
# Setup the URLs and include login URLs for the browsable API.
8586
urlpatterns = [
8687
path('admin/', admin.site.urls),
87-
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
88+
path('o/', include(oauth2_urls)),
8889
path('users/', UserList.as_view()),
8990
path('users/<pk>/', UserDetails.as_view()),
9091
path('groups/', GroupList.as_view()),

Diff for: docs/tutorial/tutorial_01.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ Include the Django OAuth Toolkit urls in your `urls.py`, choosing the urlspace y
3434
.. code-block:: python
3535
3636
from django.urls import path, include
37+
from oauth2_provider import urls as oauth2_urls
3738
3839
urlpatterns = [
3940
path("admin", admin.site.urls),
40-
path("o/", include('oauth2_provider.urls', namespace='oauth2_provider')),
41+
path("o/", include(oauth2_urls)),
4142
# ...
4243
]
4344

Diff for: tests/urls.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from django.contrib import admin
22
from django.urls import include, path
33

4+
from oauth2_provider import urls as oauth2_urls
5+
46

57
admin.autodiscover()
68

79

810
urlpatterns = [
9-
path("o/", include("oauth2_provider.urls", namespace="oauth2_provider")),
11+
path("o/", include(oauth2_urls)),
1012
path("admin/", admin.site.urls),
1113
]

0 commit comments

Comments
 (0)