Skip to main content

Django app for exposing methods to rest interface.

Project description

To install this package

pip install python-django-injector

🎯 Define Exposed Endpoints

Manager-based Endpoint

# myapp/api.py
from Injection.utils import exposeable, expose
from myapp.models import Item
from myapp.serializers import ItemSerializer

@exposeable
class ItemManager:
    def __init__(self):
        pass

    @expose(
        method='POST',
        url='api/items/filter/',
        response_serializer=ItemSerializer
    )
    def filter_items(self, name: str):
        return Item.objects.filter(name__icontains=name)

Utility Function Endpoint

from Injection.utils import expose

@expose(method='GET', url='api/ping/')
def ping():
    return {'pong': True}

Wire Up URL Patterns

from django.contrib import admin
from django.urls import path
from Injection.utils import root_instance

urlpatterns = [
    path('admin/', admin.site.urls),
    # Auto-add all @expose endpoints:
] + root_instance.export_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

python_django_injector-1.0.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

python_django_injector-1.0.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file python_django_injector-1.0.1.tar.gz.

File metadata

  • Download URL: python_django_injector-1.0.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for python_django_injector-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bcb053921336f3c11de6c48256bcbf9ea0ca759aae12b00cdaacadf1159280c0
MD5 419516b04aa9d63cf675c677c2bd3b47
BLAKE2b-256 0b12b432c46d9beaddbd0cf3c5cf0e0ff77c979923c7cc744471739327e25c3b

See more details on using hashes here.

File details

Details for the file python_django_injector-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_django_injector-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5bf39fcc665a9d5e9481e2664d650a981e837e81f5df87c8eba232f0eb1a3ab6
MD5 2aa864ccc93357b3d3428ba422ff422e
BLAKE2b-256 e225be68a4b31b7be554d31678dd873937094e3c2866195a8704cbbf3d1d290e

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