{"id":13625670,"url":"https://github.com/fengsp/django-grpc-framework","last_synced_at":"2025-04-12T21:29:07.770Z","repository":{"id":43712354,"uuid":"260614401","full_name":"fengsp/django-grpc-framework","owner":"fengsp","description":"gRPC for Django.","archived":false,"fork":false,"pushed_at":"2022-12-10T18:36:33.000Z","size":91,"stargazers_count":402,"open_issues_count":29,"forks_count":53,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-04T00:44:31.659Z","etag":null,"topics":["django","django-rest-framework","grpc","grpc-python"],"latest_commit_sha":null,"homepage":"https://djangogrpcframework.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fengsp.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-02T04:36:51.000Z","updated_at":"2025-03-29T01:43:09.000Z","dependencies_parsed_at":"2023-01-26T10:02:14.167Z","dependency_job_id":null,"html_url":"https://github.com/fengsp/django-grpc-framework","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fdjango-grpc-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fdjango-grpc-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fdjango-grpc-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengsp%2Fdjango-grpc-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fengsp","download_url":"https://codeload.github.com/fengsp/django-grpc-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248634147,"owners_count":21136991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","grpc","grpc-python"],"created_at":"2024-08-01T21:01:59.235Z","updated_at":"2025-04-12T21:29:07.750Z","avatar_url":"https://github.com/fengsp.png","language":"Python","funding_links":[],"categories":["Python","Language-Specific"],"sub_categories":["Python"],"readme":"Django gRPC Framework\n=====================\n\n.. image:: https://img.shields.io/pypi/v/djangogrpcframework.svg\n   :target: https://img.shields.io/pypi/v/djangogrpcframework.svg\n\n.. image:: https://readthedocs.org/projects/djangogrpcframework/badge/?version=latest\n   :target: https://readthedocs.org/projects/djangogrpcframework/badge/?version=latest\n\n.. image:: https://travis-ci.org/fengsp/django-grpc-framework.svg?branch=master\n   :target: https://travis-ci.org/fengsp/django-grpc-framework.svg?branch=master\n\n.. image:: https://img.shields.io/pypi/pyversions/djangogrpcframework\n   :target: https://img.shields.io/pypi/pyversions/djangogrpcframework\n\n.. image:: https://img.shields.io/pypi/l/djangogrpcframework\n   :target: https://img.shields.io/pypi/l/djangogrpcframework\n\nDjango gRPC framework is a toolkit for building gRPC services, inspired by\ndjangorestframework.\n\n\nRequirements\n------------\n\n- Python (3.6, 3.7, 3.8)\n- Django (2.2, 3.0), Django REST Framework (3.10.x, 3.11.x)\n- gRPC, gRPC tools, proto3\n\n\nInstallation\n------------\n\n.. code-block:: bash\n    \n    $ pip install djangogrpcframework\n\nAdd ``django_grpc_framework`` to ``INSTALLED_APPS`` setting:\n\n.. code-block:: python\n\n    INSTALLED_APPS = [\n        ...\n        'django_grpc_framework',\n    ]\n\n\nDemo\n----\n\nHere is a quick example of using gRPC framework to build a simple\nmodel-backed service for accessing users, startup a new project:\n\n.. code-block:: bash\n    \n    $ django-admin startproject demo\n    $ python manage.py migrate\n\nGenerate ``.proto`` file demo.proto_:\n\n.. _demo.proto: https://github.com/fengsp/django-grpc-framework/blob/master/examples/demo/demo.proto\n\n.. code-block:: bash\n\n    python manage.py generateproto --model django.contrib.auth.models.User --fields id,username,email --file demo.proto\n\nGenerate gRPC code:\n\n.. code-block:: bash\n\n    python -m grpc_tools.protoc --proto_path=./ --python_out=./ --grpc_python_out=./ ./demo.proto\n\nNow edit the ``demo/urls.py`` module:\n\n.. code-block:: python\n\n    from django.contrib.auth.models import User\n    from django_grpc_framework import generics, proto_serializers\n    import demo_pb2\n    import demo_pb2_grpc\n\n\n    class UserProtoSerializer(proto_serializers.ModelProtoSerializer):\n        class Meta:\n            model = User\n            proto_class = demo_pb2.User\n            fields = ['id', 'username', 'email']\n\n\n    class UserService(generics.ModelService):\n        queryset = User.objects.all()\n        serializer_class = UserProtoSerializer\n\n\n    urlpatterns = []\n    def grpc_handlers(server):\n        demo_pb2_grpc.add_UserControllerServicer_to_server(UserService.as_servicer(), server)\n\nThat's it, we're done!\n\n.. code-block:: bash\n    \n    $ python manage.py grpcrunserver --dev\n\nYou can now run a gRPC client to access the service:\n\n.. code-block:: python\n\n    with grpc.insecure_channel('localhost:50051') as channel:\n        stub = demo_pb2_grpc.UserControllerStub(channel)\n        for user in stub.List(demo_pb2.UserListRequest()):\n            print(user, end='')\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengsp%2Fdjango-grpc-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffengsp%2Fdjango-grpc-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengsp%2Fdjango-grpc-framework/lists"}