Django gRPC Framework
Django gRPC framework is a toolkit for building gRPC services, inspired by djangorestframework.
Requirements
Python (3.6, 3.7, 3.8)
Django (2.2, 3.0), Django REST Framework (3.10.x, 3.11.x)
gRPC, gRPC tools, proto3
Installation
$ pip install djangogrpcframework
Add django_grpc_framework to INSTALLED_APPS setting:
INSTALLED_APPS = [
...
'django_grpc_framework',
]
Demo
Here is a quick example of using gRPC framework to build a simple model-backed service for accessing users, startup a new project:
$ django-admin startproject demo
$ python manage.py migrate
Generate .proto file demo.proto:
python manage.py generateproto --model django.contrib.auth.models.User --fields id,username,email --file demo.proto
Generate gRPC code:
python -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ ./demo.proto
Now edit the demo/urls.py module:
from django.contrib.auth.models import User
from django_grpc_framework import generics, proto_serializers
import demo_pb2
import demo_pb2_grpc
class UserProtoSerializer(proto_serializers.ModelProtoSerializer):
class Meta:
model = User
proto_class = demo_pb2.User
fields = ['id', 'username', 'email']
class UserService(generics.ModelService):
queryset = User.objects.all()
serializer_class = UserProtoSerializer
urlpatterns = []
def grpc_handlers(server):
demo_pb2_grpc.add_UserControllerServicer_to_server(UserService.as_servicer(), server)
That’s it, we’re done!
$ python manage.py grpcrunserver --dev
You can now run a gRPC client to access the service:
with grpc.insecure_channel('localhost:50051') as channel:
stub = demo_pb2_grpc.UserControllerStub(channel)
for user in stub.List(demo_pb2.UserListRequest()):
print(user, end='')
Metadata
Release files for djangogrpcframework 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djangogrpcframework-0.2.1.tar.gz | 14.1 kB | Without provenance | Details for djangogrpcframework-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djangogrpcframework-0.2.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for djangogrpcframework-0.2.1-py2.py3-none-any.whl |
Total release size: 35.0 kB
Release files / djangogrpcframework-0.2.1.tar.gz
| Download URL | djangogrpcframework-0.2.1.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f96ae98d463f02745dbac5c18899801b738c79efd198e8cc709a7476533aec97
|
|
BLAKE2b-256 checksum How to use checksums |
96d974504f99dbfe1955a3f5e0ca2952cc4a7decee156822f18f0d0cf3c58328
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.3
|
Release files / djangogrpcframework-0.2.1-py2.py3-none-any.whl
| Download URL | djangogrpcframework-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c1835bd87ac9bdbdbdb631cd1c12720e711260d316303d19e4c63e53896ff0e6
|
|
BLAKE2b-256 checksum How to use checksums |
ae899a475e234786ba14fd3b538a18df0d20e98ce5a51906e1bd4485a74164e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.3
|
Security for djangogrpcframework 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.