Old Behavior
Currently, there is no existing way to easily utilize Django Forms (and django-crispy-forms) within ReactPy.
A lot of Django users have the expectation that they can use battle-tested form validation, so this is an important feature.
Implementation Details
Create a reactpy_django.components.django_form that calls Form.render(), then use html_to_vdom to convert into a ReactPy component.
By default, django_form should intercept the on_submit event for html.form to perform Django validation.
@component
def my_component():
return html.div(
django_form(MyDjangoForm),
)
We might need to be extra attentive towards some custom form fields, such as django-colorfield and django-ace, which utilize script tags directly within the form body.
Additionally, some anchor link buttons, such as those within django-crispy-forms, may require special attention as well. For example, should we automatically use reactpy_router to intercept these links? This automatic behavior might need to be a configurable setting within the component.
Old Behavior
Currently, there is no existing way to easily utilize Django Forms (and
django-crispy-forms) within ReactPy.A lot of Django users have the expectation that they can use battle-tested form validation, so this is an important feature.
Implementation Details
Create a
reactpy_django.components.django_formthat callsForm.render(), then usehtml_to_vdomto convert into a ReactPy component.By default,
django_formshould intercept theon_submitevent forhtml.formto perform Django validation.We might need to be extra attentive towards some custom form fields, such as
django-colorfieldanddjango-ace, which utilize script tags directly within the form body.Additionally, some anchor link buttons, such as those within
django-crispy-forms, may require special attention as well. For example, should we automatically usereactpy_routerto intercept these links? This automatic behavior might need to be a configurable setting within the component.