Sun praise internal backend package.
Project description
spback (sun-praise backend) framework
This project is built on django-ninja and django-ninja-extra.
Usage
Create your django project, start with the command: django-admin startproject conf ..
Update settings.py
If you need to use the feature of api, you need to install django-ninja-extra>=0.20.7, django-ninja-jwt>=5.3.1.
Add spback supported apps,
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# for example, "apis",
...
"ninja_extra", # for spback
]
API instance
create api instance.
from spback.urls import create_api
api = create_api()
JWT
If you want the JWT get authed, set the api with JWTAuth.
from ninja_extra.router import Router
from ninja_jwt.authentication import JWTAuth
router = Router()
@router.get("/", auth=JWTAuth())
def protected_endpoint(request):
return {"message": "This is a protected endpoint."}
Error handler
register error handler
from spback.handler.errors import register_error_handler
api = register_error_handler(api)
Register to urls.py
With this code, the users could register django-ninja to urls.py
api = create_api()
api = register_routers(api)
urlpatterns = [
path("", api.urls),
]
Register to conf/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("api.urls")),
]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spback-0.2.2.tar.gz.
File metadata
- Download URL: spback-0.2.2.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
148076cacc0f556a5f7e580e6cd4f4013633f8f3b1d41cd1bbbc9fecb7f419a7
|
|
| MD5 |
2af5f9cfe673e6b613cda579204ff832
|
|
| BLAKE2b-256 |
16d2df6102c39f1f0bbfb25b1c68a905d874610d6761f6cfeb2121aa29125417
|
File details
Details for the file spback-0.2.2-py3-none-any.whl.
File metadata
- Download URL: spback-0.2.2-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9baecc63fe68d96b809a8ab3bc56682c6f0c1673abd14e565a0455078b86711a
|
|
| MD5 |
f66b59f88286e36bfd07d7c13cbd1825
|
|
| BLAKE2b-256 |
827eb21a3c8ffcbd7d3f5adfa014b7a96e4b2f0c1ac21a1c0356ba8b5d24dd64
|