Skip to content

Commit a2699bf

Browse files
authored
fix: create object actions (#1072)
1 parent 94860e8 commit a2699bf

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/unfold/mixins/action_model_admin.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,25 @@ def changeform_view(
6868
"""
6969
extra_context = extra_context or {}
7070

71-
# `actions_submit_line` is a list of actions that are displayed in the submit line they
72-
# are displayed as form buttons
73-
actions_submit_line = self.get_actions_submit_line(request, object_id)
74-
75-
# `actions_detail` may contain custom structure with dropdowns so it is needed
76-
# to use `_get_actions_navigation` to build the final structure for the template
77-
actions_detail = self._get_actions_navigation(
78-
self.actions_detail,
79-
self.get_actions_detail(request, object_id),
80-
object_id,
81-
)
71+
if object_id:
72+
# `actions_submit_line` is a list of actions that are displayed in the submit line they
73+
# are displayed as form buttons
74+
actions_submit_line = self.get_actions_submit_line(request, object_id)
75+
76+
# `actions_detail` may contain custom structure with dropdowns so it is needed
77+
# to use `_get_actions_navigation` to build the final structure for the template
78+
actions_detail = self._get_actions_navigation(
79+
self.actions_detail,
80+
self.get_actions_detail(request, object_id),
81+
object_id,
82+
)
8283

83-
extra_context.update(
84-
{
85-
"actions_submit_line": actions_submit_line,
86-
"actions_detail": actions_detail,
87-
}
88-
)
84+
extra_context.update(
85+
{
86+
"actions_submit_line": actions_submit_line,
87+
"actions_detail": actions_detail,
88+
}
89+
)
8990

9091
return super().changeform_view(request, object_id, form_url, extra_context)
9192

0 commit comments

Comments
 (0)