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")),
]

For Developer

Use pdm run pip install -r requirements/requirements.dev to install dev packages.

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spback-0.2.3-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for spback-0.2.3.tar.gz
Algorithm Hash digest
SHA256 538ef6a2a9f2a49155417094569229922d7916926a2a4beb13f1c66c63feb775
MD5 08e4b03afcb0457a3225be60f8247c05
BLAKE2b-256 7bd009f4ff3018a0b0d3ae2b14e6e54faa9d06c2ce8fa5cc407936f41387893b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spback-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac16cb07ff877340c498c2ad3d0097dc272ca7236dba9738c819e44f4026005
MD5 d5bb85fb13d1a1e8a3bf5fe5fce2eb15
BLAKE2b-256 6df209db8ce5fc463984458a67e70957a1b70d01ed3c6a6c072858582776f60b

See more details on using hashes here.

Supported by

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