{"id":14384497,"url":"https://github.com/bmihelac/ra-data-django-rest-framework","last_synced_at":"2025-10-06T18:51:56.398Z","repository":{"id":41124175,"uuid":"266867691","full_name":"bmihelac/ra-data-django-rest-framework","owner":"bmihelac","description":"react-admin data provider for Django REST framework","archived":false,"fork":false,"pushed_at":"2023-01-26T21:16:57.000Z","size":3960,"stargazers_count":106,"open_issues_count":45,"forks_count":31,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T01:08:32.338Z","etag":null,"topics":["django","djdjango-rest-framework","python","react","react-admin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/bmihelac.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-25T19:52:00.000Z","updated_at":"2025-03-17T08:04:31.000Z","dependencies_parsed_at":"2023-02-15T00:16:07.297Z","dependency_job_id":null,"html_url":"https://github.com/bmihelac/ra-data-django-rest-framework","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmihelac%2Fra-data-django-rest-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmihelac%2Fra-data-django-rest-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmihelac%2Fra-data-django-rest-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmihelac%2Fra-data-django-rest-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmihelac","download_url":"https://codeload.github.com/bmihelac/ra-data-django-rest-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137887,"owners_count":21053775,"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","djdjango-rest-framework","python","react","react-admin"],"created_at":"2024-08-28T18:01:25.959Z","updated_at":"2025-10-06T18:51:51.378Z","avatar_url":"https://github.com/bmihelac.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# ra-data-django-rest-framework\n\n[react-admin](https://marmelab.com/react-admin/) data and authentication provider for [Django REST\nframework](https://www.django-rest-framework.org/).\n\n[![Stable Release](https://img.shields.io/npm/v/ra-data-django-rest-framework)](https://npm.im/ra-data-django-rest-framework)\n[![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)\n![CI](https://github.com/bmihelac/ra-data-django-rest-framework/workflows/CI/badge.svg)\n[![codecov](https://codecov.io/gh/bmihelac/ra-data-django-rest-framework/branch/master/graph/badge.svg)](https://codecov.io/gh/bmihelac/ra-data-django-rest-framework)\n\nra-data-django-rest-framework includes backend and client example application\nand tests.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/bmihelac/ra-data-django-rest-framework/blob/master/docs/ra-data-django-rest-framework.png\" alt=\"ra-data-django-rest-framework\" /\u003e\n\u003c/p\u003e\n\n## Install\n\n```bash\nnpm install ra-data-django-rest-framework\n```\n\n## Usage\n\n```javascript\nimport drfProvider from 'ra-data-django-rest-framework';\nconst dataProvider = drfProvider(\"/api\");\n```\n\n## Features\n\n* Sorting\n* Pagination\n* Filtering\n* Authentication\n\n### Sorting\n\nOrdering for\n[OrderingFilter](https://www.django-rest-framework.org/api-guide/filtering/#orderingfilter)\nis supported.\n\n### Pagination\n\nCurrently pagination with\n[PageNumberPagination](https://www.django-rest-framework.org/api-guide/pagination/#pagenumberpagination)\nis supported.\n\nDefault `PageNumberPagination` has `page_size_query_param` set to `None`,\noveride to be able to set *Rows per page*, ie:\n\n```python\nfrom rest_framework.pagination import PageNumberPagination\n\n\nclass PageNumberWithPageSizePagination(PageNumberPagination):\n    page_size_query_param = 'page_size'\n```\n\n### Filtering\n\nra-data-django-rest-framework supports:\n\n* [Generic Filtering](https://www.django-rest-framework.org/api-guide/filtering/#generic-filtering)\n* [DjangoFilterBackend](https://www.django-rest-framework.org/api-guide/filtering/#djangofilterbackend)\n\n### Authentication\n\n#### tokenAuthProvider\n\n`tokenAuthProvider` uses\n[TokenAuthentication](https://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication)\nto obtain token from django-rest-framework. User token is saved in `localStorage`.\n\n`tokenAuthProvider` accepts options as second argument with\n`obtainAuthTokenUrl` key. Default URL for obtaining a token is `/api-token-auth/`.\n\n`fetchJsonWithAuthToken` overrides *httpClient* and adds authorization header\nwith previously saved user token to every request.\n\n```javascrtipt\nimport drfProvider, { tokenAuthProvider, fetchJsonWithAuthToken } from 'ra-data-django-rest-framework';\n\nconst authProvider = tokenAuthProvider()\nconst dataProvider = drfProvider(\"/api\", fetchJsonWithAuthToken);\n```\n\n#### jwtTokenAuthProvider\n\n`jwtTokenAuthProvider` uses\n[JSON Web Token Authentication](https://www.django-rest-framework.org/api-guide/authentication/#json-web-token-authentication)\nto obtain token from django-rest-framework. User token is saved in `localStorage`.\n\n`jwtTokenAuthProvider` accepts options as second argument with\n`obtainAuthJWTTokenUrl` key. Default URL for obtaining a token is `/api/token/`.\n\n`fetchJsonWithAuthJWTToken` overrides *httpClient* and adds authorization header\nwith previously saved user token to every request.\n\n```javascrtipt\nimport drfProvider, { jwtTokenAuthProvider, fetchJsonWithAuthJWTToken } from 'ra-data-django-rest-framework';\n\nconst authProvider = jwtTokenAuthProvider()\nconst dataProvider = drfProvider(\"/api\", fetchJsonWithAuthJWTToken);\n```\n\n## Example app\n\n### Django application with django-rest-framework\n\nSetup virtual envirnoment, install requirements and load initial data:\n\n```bash\ncd example/backend\nvirtualenv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n./manage.py migrate\n./manage.py loaddata initial\n```\n\nRun server:\n\n```bash\n./manage.py runserver\n```\n\nAdmin credentials in the example app are:\n\n`admin`\n`password`\n\n### React-admin demo application\n\n```bash\nyarn install # install ra-data-django-rest-framework\ncd example/client\nyarn install\nyarn start\n```\n\nYou can now view example app in the browser: http://localhost:3000\nLogin with user `admin`, password is `password` or create new users in Django\nadmin dashboard or shell.\n\nBy default the ``rest_framework.authentication.TokenAuthentication`` will be \nused. To use ``rest_framework_simplejwt.authentication.JWTAuthentication``, set\nthe value of the ``REACT_APP_USE_JWT_AUTH`` variable in the .env \nfile (example/client/.env) to true, as shown below:\n\n```text\nREACT_APP_USE_JWT_AUTH=true\n```\n\n## Contributing\n\nThis project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).\nAll features that TSDX provides should work here too.\n\n```bash\nyarn start\n```\n\n```bash\nyarn test\n```\n\n## TODO\n\n* examples for image upload\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmihelac%2Fra-data-django-rest-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmihelac%2Fra-data-django-rest-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmihelac%2Fra-data-django-rest-framework/lists"}