Form: support passing instance as a lambda, even in combination with auto__model
@@ -1371,6 +1371,7 @@ def __init__(
include=auto.include,
exclude=auto.exclude,
)
+ if auto.instance is not None:
instance = auto.instance
if title is MISSING and auto.type is not None:
title = capitalize(
@@ -1411,6 +1412,8 @@ def on_bind(self) -> None:
request = self.get_request()
self._request_data = request_data(request)
+ self.instance = evaluate_strict(self.instance, **self.iommi_evaluate_parameters())
+
# If this is a nested form register it with the parent, need
# to do this early because is_target needs self.parent_form
if self.iommi_parent() is not None:
