Automates DRF APIs for Ant Design ProTable
drf_antd_protableautomates DRF APIs for Ant Design ProTable, enabling seamless data handling with pagination, sorting, filtering, and searching support, while automatically generating frontend table configurations.
Installation
python3 -m pip install -U drf-antd-protable
Usage
1. use as viewsets
# views.py
from drf_antd_protable.viewsets import ProTableViewSet
from . import models, serializers
class MyTableViewSet(ProTableViewSet):
queryset = models.QA.objects.all()
serializer_class = serializers.QA_Serializer
# urls.py
from rest_framework.routers import DefaultRouter
from .views import MyTableViewSet
router = DefaultRouter()
router.register('demo_table', MyTableViewSet, basename='demo_table')
urlpatterns = [
# ...
path('', include(router.urls)),
# ...
]
2. supporting columns configuration
hidden_fieldsselect_fieldssorter_fieldscopyable_fieldsnot_search_fieldsrender_region_fieldsrender_compare_fieldsverbose_name_map
example
class MyTableViewSet(ProTableViewSet):
queryset = models.QA.objects.all()
serializer_class = serializers.QA_Serializer
hidden_fields = ['id']
select_fields = ['department']
sorter_fields = ['user', 'question']
copyable_fields = ['anwser']
not_search_fields = ['department']
render_region_fields = ['size']
render_compare_fields = ['count']
verbose_name_map = {
'size': '大小',
'count': '数量',
}
Endpoints
-
demo_table/columns/ -
demo_table/data/ -
demo_table/export/
Use in Frontend
import { ProTable } from '@ant-design/pro-components'
import { useRequest } from 'ahooks'
import { request } from '@umijs/max'
const DemoTable = () => {
const columnsRequest = useRequest(async () => request('/api/demo_table/columns/'))
return (
<ProTable
columns={columnsRequest.data}
request={async (params, sorter, filter) => {
const { current, pageSize, keyword, ...search } = params;
const payload = {
sort: sorter,
filter: filter,
search: search,
globalSearch: keyword,
};
const data = await request('/api/demo_table/data/', {
method: 'POST',
data: payload,
params: { current, pageSize },
})
return data
}}
/>
)
}
Metadata
Release files for drf-antd-protable 1.0.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 |
|---|---|---|---|---|
| drf_antd_protable-1.0.1.tar.gz | 8.6 kB | Without provenance | Details for drf_antd_protable-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_antd_protable-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for drf_antd_protable-1.0.1-py3-none-any.whl |
Total release size: 17.5 kB
Release files / drf_antd_protable-1.0.1.tar.gz
| Download URL | drf_antd_protable-1.0.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23bf4029e8f7d720f415ac6217a4e572eec7a3e239d354af3e1c2e68e1cbf09b
|
|
BLAKE2b-256 checksum How to use checksums |
7ad1348f7229ee508bf6c374979ede9f2fae58f7dc53760786ea746616515b9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Release files / drf_antd_protable-1.0.1-py3-none-any.whl
| Download URL | drf_antd_protable-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dca1baa6a91fa5e6b70cec48ccd18b07e3dcb0d740de495f03d57f55e1c4611
|
|
BLAKE2b-256 checksum How to use checksums |
c5615b2f413fc0cc22354ba7bf047f906ce57b0df9c3bdd4e0f3e1ab5921579d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.8
|
Security for drf-antd-protable 1.0.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.