Skip to main content

Django app for exposing methods to rest interface.

Project description

To install this package

cd python-django-injector
pip install "dist/injector_arc-1.0.0-py3-none-any.whl"

To build this package after making updates

cd python-django-injector
python setup.py bdist_wheel

🎯 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.0.tar.gz (4.0 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.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_django_injector-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 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.0.tar.gz
Algorithm Hash digest
SHA256 71946285726dd1bb14aa25aa7ffd2f538cf49c2e8419194f440d31dd52a32955
MD5 334c255b488de9a4ab10b9bb2f19810e
BLAKE2b-256 3bf069d8eb87b4c4af072ff6b328211867edf23339055fe01ec3ace675d1b6ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_django_injector-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd6add55d3831aa5c25381eae5c02d91506d50ef63dcd3baf447f6a535d84d31
MD5 4559c4e8d11f5adc2c34d2e43118ec68
BLAKE2b-256 ab0400c6cc53a90b646d50991a2c987956b978a41f1e47c92d3225a1069c34ba

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