Skip to main content

Sun praise internal backend package.

Project description

spback (sun-praise backend) framework

PyPI Documentation Status Downloads

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

spback-0.2.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

spback-0.2.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file spback-0.2.0.tar.gz.

File metadata

  • Download URL: spback-0.2.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for spback-0.2.0.tar.gz
Algorithm Hash digest
SHA256 16fc5b14bceca6626506cd1642c04cca3b2708b886fbd7c94969f1509a5894d2
MD5 308608555dbe4c0a211eab9f3071c1a4
BLAKE2b-256 03912df2df6c77c77335915eff9084a86c545146a4ebd70c41657a9ecca056de

See more details on using hashes here.

File details

Details for the file spback-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: spback-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for spback-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49aafbed77a5064886f3a547becbc5bc337b5462f4fb0a7212f89622dcd4ef09
MD5 1ec30066f008b434b0c4567085fa0309
BLAKE2b-256 d2e1634514f0f8d461c25b25d1dc59cf0eedcb762ac21eae59253139b5f9abd1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page