88from django .forms import Form , ModelForm
99from reactpy import component , hooks , html , utils
1010from reactpy .core .events import event
11- from reactpy .core .types import VdomDict
1211from reactpy .web import export , module_from_file
1312
1413from reactpy_django .forms .transforms import (
2423if TYPE_CHECKING :
2524 from collections .abc import Sequence
2625
26+ from reactpy .core .types import VdomDict
27+
2728DjangoForm = export (
2829 module_from_file ("reactpy-django" , file = Path (__file__ ).parent .parent / "static" / "reactpy_django" / "client.js" ),
2930 ("DjangoForm" ),
@@ -44,6 +45,8 @@ def _django_form(
4445 top_children : Sequence ,
4546 bottom_children : Sequence ,
4647):
48+ from reactpy_django import config
49+
4750 uuid_ref = hooks .use_ref (uuid4 ().hex .replace ("-" , "" ))
4851 top_children_count = hooks .use_ref (len (top_children ))
4952 bottom_children_count = hooks .use_ref (len (bottom_children ))
@@ -84,7 +87,9 @@ async def render_form():
8487 await database_sync_to_async (initialized_form .save )()
8588 set_submitted_data (None )
8689
87- new_form = await database_sync_to_async (initialized_form .render )(form_template )
90+ new_form = await database_sync_to_async (initialized_form .render )(
91+ form_template or config .REACTPY_DEFAULT_FORM_TEMPLATE
92+ )
8893 if new_form != rendered_form :
8994 set_rendered_form (new_form )
9095
0 commit comments