浏览代码

fix backend vars

Benedikt Bartscher 1 年之前
父节点
当前提交
66f1e21576
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      reflex/state.py

+ 4 - 0
reflex/state.py

@@ -155,6 +155,9 @@ RESERVED_BACKEND_VAR_NAMES = {
     "_was_touched",
 }
 
+SPECIAL_METHODS = {
+    "model_post_init",  # never treat this as an event handler
+}
 
 def _substate_key(
     token: str,
@@ -517,6 +520,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
         """
         return (
             not name.startswith("_")
+            and name not in SPECIAL_METHODS
             and isinstance(value, Callable)
             and not isinstance(value, EventHandler)
             and hasattr(value, "__code__")