Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve django_form limitations #270

Open
5 tasks
Archmonger opened this issue Dec 7, 2024 · 0 comments
Open
5 tasks

Resolve django_form limitations #270

Archmonger opened this issue Dec 7, 2024 · 0 comments

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Dec 7, 2024

Current Situation and Proposed Actions


The following fields are currently incompatible with django_form due to ReactPy's client and server not supporting file serialization:

  • FileField
  • ImageField

Resolving this will require implementing some sort of messaging 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.

It might be difficult to figure out what to do on early websocket termination. It might also make sense to create a messaging schema where the server can control the incoming upload speed.


The following fields 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.

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.


The following limitation will 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_method that can be set to "URL", "CLIENT_LOCAL_STORAGE", "SERVER_SESSION", or None. Note that "URL" mode would likely limit the user to one form per page.
    • Maybe we need to mandate the user provides a key for 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's scope["session"]? This needs some additional thought.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant