Resolve `django_form` limitations
已經有一個關聯 PR 被合併了。
- #298 來自 @Archmonger —— 已合併
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 功能
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- python, react
- 領域
- full-stack
研究方向
Start by reading the client code under src/js/src and the server websocket entry point in src/reactpy_django/websocket/consumer.py, then review the related draft PR #859 and the merged work in #298. Done means the unresolved FileField and ImageField limitations and form restoration on page reload have defined, working behavior.
由索引模型根據 Issue 內容生成。
描述
Current Situation and Proposed Actions
Serializable data fields do not work (Unresolved)
The following fields are currently incompatible with django_form due to ReactPy's client and server not supporting file serialization:
-
FileField -
ImageField
My two initial ideas on how to solve this:
- Extend the current implementation but use a custom messaging schema
- Specifically, adding some sort of messaging websocket schema that can differentiate between layout messages and file transfers.
- On the server-side, we could consider re-using Django's UploadHandler.
- The UploadHandler will probably need to be subclassed to get things working with ReactPy.
- Determine how to pipe the HTTP client/server stack through a websocket
- This would be convenient - specifically would enable us to retain the exact same upload behavior that users would expect on any specific Django version
It might be difficult to figure out what to do on early websocket termination. It might also make sense to create a throttling system where the server can control the incoming upload speed.
There was a related draft PR for file uploads that could be leveraged for inspiration.
Multiple choice fields do not work (Fixed in #298)
There is an additional set of fields that are currently incompatible with django_form, and this seems to be caused by weirdness with how Django re-hydrates/re-renders the form submission data:
-
SplitDateTimeField -
MultiValueField
When the form data is submitted, those fields don't properly rehydrate themselves when given form submission data. This causes incorrect re-renders.
This might just be a limitation of our current rendering methodology. If that is true, then fixing this will require digging into Django's form rendering stack and figuring out why they don't rehydrate properly when given the expected values.
Form restoration on page load (Unresolved)
The following limitation will also need to be resolved:
- Implement form restoration on page reload.
- Perhaps pre-rendering plus the browser's default behavior may already handle form restoration well enough? Probably not, but this should be investigated.
- Maybe this involves creating a new setting called
form_restoration_methodthat can be set to"URL","CLIENT_LOCAL_STORAGE","SERVER_SESSION", orNone. Note that "URL" mode would likely limit the user to one form per page. - Maybe we need to mandate the user provides a
keyfor the form if using form restoration in order to properly re-hydrate the form? Or perhaps we can use the form's CSRF token as the key? Or perhaps it can be linked directly to the browser'sscope["session"]? This needs some additional thought.
- 主要語言
- Python
- 星號
- 357
- 分支
- 22
- 平均合併
- 10 小時 31 分鐘
- 30 天內合併 PR
- 2
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
reactive-python/reactpy-django 的其他 Issue
-
complexity: 3 (low) priority: 3 (low) type: ci
難度 3/5 1-2 天 新手友好度 45/100
-
complexity: 2 (medium) priority: 3 (low)
難度 5/5 一週以上 新手友好度 25/100
-
complexity: 2 (medium) priority: 3 (low)
難度 5/5 一週以上 新手友好度 25/100
-
complexity: 1 (high) priority: 2 (moderate)
難度 5/5 一週以上 新手友好度 25/100
-
complexity: 2 (medium) priority: 2 (moderate) type: investigation
難度 5/5 一週以上 新手友好度 20/100
查看 reactive-python/reactpy-django 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 74/100