Skip to content

Simplify urlpattern loading #1436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Hiroki Kiyohara
Hossein Shakiba
Islam Kamel
Ivan Lukyanets
Jaap Roes
Jadiel Teófilo
Jens Timmerman
Jerome Leclanche
Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ Add ``oauth2_provider`` to your ``INSTALLED_APPS``


If you need an OAuth2 provider you'll want to add the following to your ``urls.py``.
Notice that ``oauth2_provider`` namespace is mandatory.

.. code-block:: python

from oauth2_provider import urls as oauth2_urls

urlpatterns = [
...
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('o/', include(oauth2_urls)),
]

Changelog
Expand Down
3 changes: 2 additions & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ Include ``oauth2_provider.urls`` to :file:`iam/urls.py` as follows:

from django.contrib import admin
from django.urls import include, path
from oauth2_provider import urls as oauth2_urls

urlpatterns = [
path('admin/', admin.site.urls),
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('o/', include(oauth2_urls)),
]

This will make available endpoints to authorize, generate token and create OAuth applications.
Expand Down
3 changes: 2 additions & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ If you need an OAuth2 provider you'll want to add the following to your :file:`u
.. code-block:: python

from django.urls import include, path
from oauth2_provider import urls as oauth2_urls

urlpatterns = [
...
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('o/', include(oauth2_urls),
]

Sync your database
Expand Down
3 changes: 2 additions & 1 deletion docs/rest-framework/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Here's our project's root :file:`urls.py` module:

from rest_framework import generics, permissions, serializers

from oauth2_provider import urls as oauth2_urls
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope, TokenHasScope

# first we define the serializers
Expand Down Expand Up @@ -84,7 +85,7 @@ Here's our project's root :file:`urls.py` module:
# Setup the URLs and include login URLs for the browsable API.
urlpatterns = [
path('admin/', admin.site.urls),
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
path('o/', include(oauth2_urls)),
path('users/', UserList.as_view()),
path('users/<pk>/', UserDetails.as_view()),
path('groups/', GroupList.as_view()),
Expand Down
3 changes: 2 additions & 1 deletion docs/tutorial/tutorial_01.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ Include the Django OAuth Toolkit urls in your `urls.py`, choosing the urlspace y
.. code-block:: python

from django.urls import path, include
from oauth2_provider import urls as oauth2_urls

urlpatterns = [
path("admin", admin.site.urls),
path("o/", include('oauth2_provider.urls', namespace='oauth2_provider')),
path("o/", include(oauth2_urls)),
# ...
]

Expand Down
4 changes: 3 additions & 1 deletion tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.contrib import admin
from django.urls import include, path

from oauth2_provider import urls as oauth2_urls


admin.autodiscover()


urlpatterns = [
path("o/", include("oauth2_provider.urls", namespace="oauth2_provider")),
path("o/", include(oauth2_urls)),
path("admin/", admin.site.urls),
]
Loading