Skip to content

Commit 41e3f11

Browse files
authored
feat(api): upgrade endpoints from DRF to Ninja apis
feat(api): upgrade endpoints from DRF to Ninja apis
2 parents 418d701 + ee46fc5 commit 41e3f11

17 files changed

Lines changed: 843 additions & 760 deletions

arena_account/settings.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@
104104
"allauth.account",
105105
"allauth.socialaccount",
106106
"allauth.socialaccount.providers.google",
107-
"rest_framework",
108-
"rest_framework.authtoken",
109-
"rest_framework_swagger",
110-
"drf_yasg",
111107
"users.apps.UsersConfig",
112108
]
113109

@@ -116,21 +112,6 @@
116112
"allauth.account.auth_backends.AuthenticationBackend",
117113
)
118114

119-
REST_FRAMEWORK = {
120-
"DEFAULT_RENDERER_CLASSES": [
121-
"rest_framework.renderers.JSONRenderer",
122-
"rest_framework.renderers.BrowsableAPIRenderer",
123-
"rest_framework.renderers.OpenAPIRenderer",
124-
],
125-
"DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema",
126-
"DEFAULT_PARSER_CLASSES": [
127-
"rest_framework.parsers.FormParser",
128-
"rest_framework.parsers.MultiPartParser",
129-
"rest_framework.parsers.JSONParser",
130-
],
131-
"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.NamespaceVersioning",
132-
}
133-
134115
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
135116

136117
# allauth general config
@@ -206,6 +187,7 @@
206187
"django.contrib.messages.middleware.MessageMiddleware",
207188
"django.middleware.clickjacking.XFrameOptionsMiddleware",
208189
"allauth.account.middleware.AccountMiddleware",
190+
"users.middleware.VersioningMiddleware",
209191
]
210192

211193
ROOT_URLCONF = "arena_account.urls"
@@ -280,6 +262,7 @@
280262
STATICFILES_DIRS = [
281263
os.path.join(BASE_DIR, "static"),
282264
]
265+
SILENCED_SYSTEM_CHECKS = ["staticfiles.W004"]
283266
else:
284267
# Static root
285268
STATIC_ROOT = "./static"

arena_account/urls.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
1616
from django.contrib import admin
17-
from django.contrib.auth import views as auth_views
1817
from django.urls import include, path
18+
from users.api import apis
1919

2020
urlpatterns = [
21-
# configure user api version based endpoints
22-
path("user/", include("users.urls", namespace="v1")),
23-
path("user/v2/", include("users.urls", namespace="v2")),
24-
21+
# configure user api version-based django views
22+
path("user/", include(("users.urls", "users"), namespace="v1")),
23+
path("user/v2/", include(("users.urls", "users"), namespace="v2")),
2524
# include admin paths
2625
path("user/admin/", admin.site.urls),
2726
path("user/accounts/", include("allauth.urls")),
2827
]
28+
29+
# configure user api version-based ninja api endpoints
30+
for version, api in apis.items():
31+
if version == "v1":
32+
urlpatterns.insert(0, path("user/", api.urls)) # v1 default
33+
else:
34+
urlpatterns.insert(1, path(f"user/{version}/", api.urls))

requirements.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ django-allauth[socialaccount]==65.14.0
44
pyjwt==2.11.0
55
cryptography==46.0.5
66
google-api-python-client==2.187.0
7-
djangorestframework==3.16.1
8-
django-rest-swagger==2.2.0
9-
coreapi==2.3.3
10-
pyyaml==6.0.3
11-
uritemplate==4.2.0
12-
drf-yasg==1.21.14
137
python-dotenv==1.2.1
148
requests==2.32.5
159
django-autocomplete-light==3.12.1
1610
pymongo==4.10.1
11+
django-ninja==1.3.0

0 commit comments

Comments
 (0)