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.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: spback-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 92a24e20a890fee0c1a5084a66f13943138c712d0f86618eb413f7d87a1126cb
MD5 b68de55d415f836ff91baa2dbe77ca8e
BLAKE2b-256 b00a56ea3181bfa9dcfc8617bc3b700125870902b7f2a24be16cfacdcdd80808

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spback-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 57735f65ed1d517b1367cb265e7cedcf876627c937cde1e23b926e475a21f468
MD5 5ade781fff82465b8a938b697ba7f36f
BLAKE2b-256 e7b126b34903df03adbc748fb98a302e6a56fac1a5bdaffa94466fef9bc981ac

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