Skip to content

Commit 205d0de

Browse files
authored
bumped up required python and updated the docs (#31)
1 parent 28b3571 commit 205d0de

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

docs/customizing_token_claims.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ from ninja import NinjaAPI
6868
api = NinjaAPI()
6969
api.add_router('', tags=['Auth'], router=router)
7070
```
71+
Also, its important to note that `NinjaExtra` registers a handler for `APIException` class which is not available in `NinjaAPI` instance.
72+
To fix that, you need the extra code below:
73+
74+
```python
75+
from ninja import NinjaAPI
76+
from ninja_extra import exceptions
77+
78+
api = NinjaAPI()
79+
api.add_router('', tags=['Auth'], router=router)
80+
81+
def api_exception_handler(request, exc):
82+
headers = {}
83+
84+
if isinstance(exc.detail, (list, dict)):
85+
data = exc.detail
86+
else:
87+
data = {"detail": exc.detail}
88+
89+
response = api.create_response(request, data, status=exc.status_code)
90+
for k, v in headers.items():
91+
response.setdefault(k, v)
92+
93+
return response
94+
95+
api.exception_handler(exceptions.APIException)(api_exception_handler)
96+
```
97+
7198

7299

73100
### Controller Schema Swapping

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = [
1212
{name = "Ezeudoh Tochukwu", email = "[email protected]"},
1313
]
1414
dynamic = ["version", "description"]
15-
requires-python = ">=3.6"
15+
requires-python = ">=3.7"
1616
readme = "README.md"
1717
home-page = "https://github.com/eadwinCode/django-ninja-jwt"
1818
classifiers = [
@@ -29,7 +29,6 @@ classifiers = [
2929
"Intended Audience :: Developers",
3030
"License :: OSI Approved :: MIT License",
3131
"Programming Language :: Python :: 3",
32-
"Programming Language :: Python :: 3.6",
3332
"Programming Language :: Python :: 3.7",
3433
"Programming Language :: Python :: 3.8",
3534
"Programming Language :: Python :: 3.9",

0 commit comments

Comments
 (0)