cuz-toolkit
自家 Django 常用功能庫:Admin 權限 Mixin、ECPay 協議層、台灣地址/銀行資料、測試工具、Unfold 擴充。
完整功能索引見 INDEX.md(每個公開 symbol 一行「做什麼+import 路徑」;改公開 API 時同步更新)。
安裝
# 一般安裝(PyPI)
uv add cuz-toolkit
# 本機開發(editable,改完立即生效)
uv add --editable ../cuz-toolkit
套件 import 名稱是 toolkit:from toolkit.admin import OwnerMixin。
模組總覽
| 模組 | 做什麼 |
|---|---|
toolkit.admin |
Django Admin 權限控制 Mixin(Owner/ReadOnly/CRUD/ActionsOnly…,含 Inline 版) |
toolkit.ecpay |
ECPay 綠界協議層:CheckMacValue 簽名、回呼驗證、付款方式常數(不含業務邏輯) |
toolkit.testing |
測試用 DB 檢查:資料表約束/索引存在性驗證(跨資料庫) |
toolkit.tw_address |
台灣縣市/區域連動下拉選單的 Admin 整合 |
toolkit.tw_banks |
台灣銀行代碼查詢+Django choices |
toolkit.unfold |
Unfold 擴充:Trix 編輯器圖片上傳、UI 中文翻譯 |
toolkit.utils |
通用工具:唯一檔名 upload_to 產生器 |
toolkit.pytest_plugin |
pytest plugin(自動啟用):coverage 舊檔清理、VSCode xdist worker 修正 |
快速上手
Admin 權限(使用者只能管自己的資料)
from django.contrib import admin
from toolkit.admin import OwnerMixin
from unfold.admin import ModelAdmin
@admin.register(Project)
class ProjectAdmin(OwnerMixin, ModelAdmin):
owner_field = "user" # 支援巢狀路徑:如 "order__user"
測試驗 DB 索引
from toolkit.testing import has_index_on_columns
def test_status_index_exists():
assert has_index_on_columns("invoice", ["status", "created_at"])
Unfold Trix 圖片上傳
# settings.py:INSTALLED_APPS 加 "toolkit.unfold"(須排在 "unfold.contrib.forms" 之前)
# urls.py:path("", include("toolkit.unfold.urls"))
from django.db import models
from toolkit.unfold import TrixUploadWidget
class ArticleAdmin(ModelAdmin):
formfield_overrides = {models.TextField: {"widget": TrixUploadWidget}}
開發
uv run pytest
uv run mypy src/
uv run ruff check src/
改到公開 API(新增/改名/刪除 symbol、改設定需求)→ 同步更新 INDEX.md。
License
MIT
Metadata
Release files for cuz-toolkit 0.3.0
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 |
|---|---|---|---|---|
| cuz_toolkit-0.3.0.tar.gz | 105.7 kB | Without provenance | Details for cuz_toolkit-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cuz_toolkit-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cuz_toolkit-0.3.0-py3-none-any.whl |
Total release size: 168.1 kB
Release files / cuz_toolkit-0.3.0.tar.gz
| Download URL | cuz_toolkit-0.3.0.tar.gz |
|---|---|
| Size | 105.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ab2bab855e826af423eaf024d0d0bda0dee9d7062c2cf77743d435a217ebcb9
|
|
BLAKE2b-256 checksum How to use checksums |
22212b4f5f9e5acd065d6273509d78cc44b3bf09c9e76e9f1a4e82acc07f4436
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.0
|
Release files / cuz_toolkit-0.3.0-py3-none-any.whl
| Download URL | cuz_toolkit-0.3.0-py3-none-any.whl |
|---|---|
| Size | 62.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b733b75c619d207bb54e8cb5cdee40a2e99a081a6f48275b3990b4b2001423e
|
|
BLAKE2b-256 checksum How to use checksums |
49ef15f26baa97fee1bb6c7063f29bfbd2541ccb5149dc12db4eb05e9d5262e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.0
|
Security for cuz-toolkit 0.3.0
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.