Skip to main content

Sun praise internal backend package.

Project description

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/dev.txt 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.7.tar.gz (153.4 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.7-py3-none-any.whl (164.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spback-0.2.7.tar.gz
  • Upload date:
  • Size: 153.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for spback-0.2.7.tar.gz
Algorithm Hash digest
SHA256 cb6164478f77dbc9a3b4f261a0e2ebb78f88bb02984345db529f4f36e4a24979
MD5 517c43f6203b09c8dda96e090e21800a
BLAKE2b-256 87000115f8b55eab7c839d97231f0a18824420c872d78fbb3000228fbe768ced

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spback-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 164.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for spback-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 22eef9ddae774f138eb38216b427efb902fe2adea2409482c700b1c9f362f584
MD5 db72f15294d4d1e4b52f66c06e8baa52
BLAKE2b-256 3d62342422d4dca2441a5d3e9ccdd08937afc9d0d2227a51c8f56d6f39865fb4

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