Skip to main content

Django AMIS 风格的 RESTful API 工具包

Project description

Django AMIS

Django AMIS 是一个为 Django REST Framework 提供 AMIS 风格接口的工具包,简化了 RESTful API 的开发过程。

功能特性

  • 自动生成查询集(queryset)和序列化器(serializer_class)
  • 支持自动检测模型字段作为筛选字段
  • 内置 AMIS 风格的响应格式化
  • 支持数据导出(Excel、CSV)
  • 可插拔的 Django 应用设计

安装

# 使用 uv 安装
uv install django-amis

# 或使用 pip
pip install django-amis

使用方法

  1. amis_rest 添加到你的 Django 项目的 INSTALLED_APPS 中:
# settings.py
INSTALLED_APPS = [
    # ...
    'rest_framework',
    'django_filters',
    'amis_rest',
    # ...
]
  1. 在你的视图中继承 AmisModelViewSet
# views.py
from amis_rest.views import AmisModelViewSet
from .models import YourModel

class YourModelViewSet(AmisModelViewSet):
    model = YourModel  # 设置模型类
    # 不需要手动设置 queryset 和 serializer_class
  1. 在你的 URL 配置中注册视图集,注意需要指定 basename:
# urls.py
from rest_framework.routers import DefaultRouter
from .views import YourModelViewSet

router = DefaultRouter()
router.register(r"your-models", YourModelViewSet, basename='yourmodel')

urlpatterns = [
    # ...
    *router.urls,
]

配置

Django AMIS 使用 Django REST Framework 的标准配置。你可以在 settings.py 中添加以下配置:

# settings.py
REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'amis_rest.pagination.AmisPagination',
    'PAGE_SIZE': 10,
    # 其他 DRF 配置...
}

许可证

本项目使用 MIT 许可证。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_amis-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_amis-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file django_amis-0.1.0.tar.gz.

File metadata

  • Download URL: django_amis-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for django_amis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f35efbe84f3c29512231d44be9400b73652e45d036c24c8b7d856d4d8256e42d
MD5 434fad22527341a9b17e688a4b0d5509
BLAKE2b-256 e0640a2eb9df804138b01a6af41247b8820ee91de83210ac7c65181ff9f261a2

See more details on using hashes here.

File details

Details for the file django_amis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_amis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 202c0d76915123f4b3906b65417b200fef24269a851201ea9d8a986a18febcda
MD5 cd2fbe1b329e20e83042964e8d1b4671
BLAKE2b-256 1581ca496993800cf54cf3aec0a24d31d83909238a8f8d7f5e3284f150601be6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page