ra-data-drf

A React-admin data provider for backends built with Django REST Framework

  • 所有者: synaptic-cl/ra-data-drf
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

ra-data-drf

A React-admin data provider for backends built with Django REST Framework

Installation

npm install --save ra-data-drf

Usage

// in App.js
import React from 'react';
import { Admin, Resource } from 'react-admin';
import drfProvider from 'ra-data-drf';
import { UserList } from './users';

const App = () => (
    <Admin dataProvider={drfProvider('http://path.to.api/')}>
        <Resource name="users" list={UserList} />
    </Admin>
);

export default App;

Features

This package was built to work with the default configurations of a Django app using Django REST Framework. It currently supports:

Sorting

This data provider translates react-admin's sorting requests from sort=["field","ASC"] and sort=["field","DESC"] to ordering=field and ordering=-field, respectively. react-admin only allows sorting by one column at a time, so multi-column sorting is NOT supported (even though DRF supports it).

It's intended to work with DRF's OrderingFilter, but it should work with any other sorting solution as long as it uses the same query string parameter and format.

Pagination

This data provider implements pagination using the page and page_size query string parameters, indicating the range of results we're requesting and the number of results we're expecting in the response, respectively. In order to render correctly, react-admin needs to know the total amount of results, which we can get from the count value included in the default response from DRF.

It's intended to work with DRF's PageNumberPagination, but it should work with any other pagination solution as long as it uses the same query string parameters and the response includes either a count value or a Content-range header with the total number of results.

Filtering

Apart from those already mentioned, every other query string parameter will be considered as a filter by DRF. This is intended to work with django-filter's DjangoFilterBackend, but it should work with any other filtering solution that uses query string parameters as filters.

主要指標

概覽
名稱與所有者synaptic-cl/ra-data-drf
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2018-11-12 19:48:18
推送於2021-03-03 14:43:39
最后一次提交2019-03-05 14:45:35
發布數2
最新版本名稱v2.0.0 (發布於 2019-03-05 14:43:38)
第一版名稱v1.0.2 (發布於 2019-02-19 11:15:30)
用户参与
星數91
關注者數12
派生數19
提交數36
已啟用問題?
問題數5
打開的問題數5
拉請求數5
打開的拉請求數1
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?