{"id":13625503,"url":"https://github.com/yezyilomo/django-restql","last_synced_at":"2026-01-11T23:57:31.826Z","repository":{"id":34640158,"uuid":"179890697","full_name":"yezyilomo/django-restql","owner":"yezyilomo","description":"Turn your API made with Django REST Framework(DRF) into a GraphQL like API.","archived":false,"fork":false,"pushed_at":"2025-02-14T22:17:46.000Z","size":1946,"stargazers_count":619,"open_issues_count":26,"forks_count":44,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-10T09:33:50.514Z","etag":null,"topics":["api","django-graphene","django-graphql","django-rest-framework","django-restql","djangorestframework","drf","dynamic-fields","graphql","nested-fields","nested-resources"],"latest_commit_sha":null,"homepage":"https://yezyilomo.github.io/django-restql","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yezyilomo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"patreon":"yezyilomo","open_collective":"django-restql"}},"created_at":"2019-04-06T21:53:41.000Z","updated_at":"2025-03-18T13:52:20.000Z","dependencies_parsed_at":"2024-02-14T04:45:05.450Z","dependency_job_id":null,"html_url":"https://github.com/yezyilomo/django-restql","commit_stats":{"total_commits":504,"total_committers":5,"mean_commits":100.8,"dds":0.04960317460317465,"last_synced_commit":"41815bd025b684952c41d41cca74012e3422c617"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yezyilomo%2Fdjango-restql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yezyilomo%2Fdjango-restql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yezyilomo%2Fdjango-restql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yezyilomo%2Fdjango-restql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yezyilomo","download_url":"https://codeload.github.com/yezyilomo/django-restql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943428,"owners_count":21186958,"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":["api","django-graphene","django-graphql","django-rest-framework","django-restql","djangorestframework","drf","dynamic-fields","graphql","nested-fields","nested-resources"],"created_at":"2024-08-01T21:01:56.919Z","updated_at":"2026-01-11T23:57:31.821Z","avatar_url":"https://github.com/yezyilomo.png","language":"Python","funding_links":["https://patreon.com/yezyilomo","https://opencollective.com/django-restql"],"categories":["Python","Packages"],"sub_categories":["Other"],"readme":"# \u003cimg height=\"24\" src=\"https://raw.githubusercontent.com/yezyilomo/django-restql/master/docs/img/icon.svg\" /\u003e [  Django RESTQL](https://yezyilomo.github.io/django-restql)\n\n![Build Status](https://github.com/yezyilomo/django-restql/actions/workflows/main.yml/badge.svg?branch=master)\n[![Latest Version](https://img.shields.io/pypi/v/django-restql.svg)](https://pypi.org/project/django-restql/) \n[![Python Versions](https://img.shields.io/pypi/pyversions/django-restql.svg)](https://pypi.org/project/django-restql/) \n[![License](https://img.shields.io/pypi/l/django-restql.svg)](https://pypi.org/project/django-restql/)\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; \n[![Downloads](https://pepy.tech/badge/django-restql)](https://pepy.tech/project/django-restql) \n[![Downloads](https://pepy.tech/badge/django-restql/month)](https://pepy.tech/project/django-restql) \n[![Downloads](https://pepy.tech/badge/django-restql/week)](https://pepy.tech/project/django-restql)\n\n\n**Django RESTQL** is a python library which allows you to turn your API made with **Django REST Framework(DRF)** into a GraphQL like API. With **Django RESTQL** you will be able to\n\n* Send a query to your API and get exactly what you need\n\n* Control the data you get on client side.\n\n* Get predictable results, since you control what you get from the server.\n\n* Get nested resources in a single request.\n\n* Avoid Over-fetching and Under-fetching of data.\n\n* Write(create \u0026 update) nested data of any level in a single request.\n\nIsn't it cool?.\n\nWant to see how this library is making all that possible? \n\nCheck out the full documentation at [https://yezyilomo.github.io/django-restql](https://yezyilomo.github.io/django-restql)\n\nOr try a live demo on [Django RESTQL Playground](https://django-restql-playground.yezyilomo.me)\n\n\n## Requirements\n* Python \u003e= 3.6\n* Django \u003e= 1.11\n* Django REST Framework \u003e= 3.5\n\n\n## Installing\n```py\npip install django-restql\n```\n\n\n## Getting Started\nUsing **Django RESTQL** to query data is very simple, you just have to inherit the `DynamicFieldsMixin` class when defining a serializer that's all.\n```py\nfrom rest_framework import serializers\nfrom django.contrib.auth.models import User\nfrom django_restql.mixins import DynamicFieldsMixin\n\n\nclass UserSerializer(DynamicFieldsMixin, serializer.ModelSerializer):\n    class Meta:\n        model = User\n        fields = [\"id\", \"username\", \"email\"]\n```\n\n**Django RESTQL** handle all requests with a `query` parameter, this parameter is the one used to pass all fields to be included/excluded in a response. For example to select `id` and `username` fields from User model, send a request with a ` query` parameter as shown below.\n\n`GET /users/?query={id, username}`\n```js\n[\n    {\n        \"id\": 1,\n        \"username\": \"yezyilomo\"\n    },\n    ...\n]\n```\n\n**Django RESTQL** support querying both flat and nested resources, so you can expand or query nested fields at any level as defined on a serializer. In an example below we have `location` as a nested field on User model.\n\n```py\nfrom rest_framework import serializers\nfrom django.contrib.auth.models import User\nfrom django_restql.mixins import DynamicFieldsMixin\n\nfrom app.models import GroupSerializer, LocationSerializer\n\n\nclass LocationSerializer(DynamicFieldsMixin, serializer.ModelSerializer):\n    class Meta:\n        model = Location\n        fields = [\"id\", \"country\",  \"city\", \"street\"]\n\n\nclass UserSerializer(DynamicFieldsMixin, serializer.ModelSerializer):\n    location = LocationSerializer(many=False, read_only=True) \n    class Meta:\n        model = User\n        fields = [\"id\", \"username\", \"email\", \"location\"]\n```\n\nIf you want only `country` and `city` fields on a `location` field when retrieving users here is how you can do it\n\n`GET /users/?query={id, username, location{country, city}}`\n```js\n[\n    {\n        \"id\": 1,\n        \"username\": \"yezyilomo\",\n        \"location\": {\n            \"contry\": \"Tanzania\",\n            \"city\": \"Dar es salaam\"\n        }\n    },\n    ...\n]\n```\n\nYou can even rename your fields when querying data, In an example below the field `location` is renamed to `address`\n\n`GET /users/?query={id, username, address: location{country, city}}`\n```js\n[\n    {\n        \"id\": 1,\n        \"username\": \"yezyilomo\",\n        \"address\": {\n            \"contry\": \"Tanzania\",\n            \"city\": \"Dar es salaam\"\n        }\n    },\n    ...\n]\n```\n\n\n## [Documentation :pencil:](https://yezyilomo.github.io/django-restql)\nYou can do a lot with **Django RESTQL** apart from querying data, like\n- Rename fields\n- Restrict some fields on nested fields\n- Define self referencing nested fields\n- Optimize data fetching on nested fields\n- Data filtering and pagination by using query arguments\n- Data mutation(Create and update nested data of any level in a single request)\n\nFull documentation for this project is available at [https://yezyilomo.github.io/django-restql](https://yezyilomo.github.io/django-restql), you are advised to read it inorder to utilize this library to the fullest.\n\n\n## [Django RESTQL Play Ground](https://django-restql-playground.yezyilomo.me)\n[**Django RESTQL Play Ground**](https://django-restql-playground.yezyilomo.me) is a graphical, interactive, in-browser tool which you can use to test **Django RESTQL** features like data querying, mutations etc to get the idea of how the library works before installing it. It's more like a [**live demo**](https://django-restql-playground.yezyilomo.me) for **Django RESTQL**, it's available at [https://django-restql-playground.yezyilomo.me](https://django-restql-playground.yezyilomo.me)\n\n\n## Running Tests\n`python runtests.py`\n\n\n## Writing \u0026 Deploying Docs\nRun `pip3 install mkdocs-material` to install mkdocs-material\n\nRun `mkdocs serve` to serve docs locally\n\nRun `mkdocs gh-deploy --force` to deploy docs to gh-page\n\n\n## Credits\n* Implementation of this library is based on the idea behind [GraphQL](https://graphql.org/).\n* My intention is to extend the capability of [drf-dynamic-fields](https://github.com/dbrgn/drf-dynamic-fields) library to support more functionalities like allowing to query nested fields both flat and iterable at any level and allow writing on nested fields while maintaining simplicity.\n\n\n## Contributing [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\nWe welcome all contributions. Please read our [CONTRIBUTING.md](https://github.com/yezyilomo/django-restql/blob/master/CONTRIBUTING.md) first. You can submit any ideas as [pull requests](https://github.com/yezyilomo/django-restql/pulls) or as [GitHub issues](https://github.com/yezyilomo/django-restql/issues). If you'd like to improve code, check out the [Code Style Guide](https://github.com/yezyilomo/django-restql/blob/master/CONTRIBUTING.md#styleguides) and have a good time!.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyezyilomo%2Fdjango-restql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyezyilomo%2Fdjango-restql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyezyilomo%2Fdjango-restql/lists"}