1
フラスコ管理者が新しく、削除ボタンを編集ビューに移動する必要があります。フラスコ管理 - ビューを編集するために削除ボタンを移動
ここに他のビューが継承しているAdminModelViewクラスがあります。
class AdminModelView(sqla.ModelView):
can_view_details = True
# column_extra_row_actions = [ViewRowAction()]
def is_accessible(self):
if not current_user.is_active or not current_user.is_authenticated:
return False
if current_user.can('administrator'):
return True
return False
def _handle_view(self, name, **kwargs):
"""
Override builtin _handle_view in order to redirect users when a view is not accessible.
"""
if not self.is_accessible():
if current_user.is_authenticated:
# permission denied
abort(403)
else:
# login
return redirect(url_for('auth.login', next=request.url))
print(self._edit_form_class)
def get_list_row_actions(self):
"""
Return list of row action objects, each is instance of
:class:`~flask_admin.model.template.BaseListRowAction`
"""
actions = []
if self.can_view_details:
if self.details_modal:
actions.append(template.ViewPopupRowAction())
else:
actions.append(template.ViewRowAction())
return actions + (self.column_extra_row_actions or [])
私が編集を取り、リストビューのオフボタンを削除するget_list_row_actions
を再定義しました。 AdminModelView
クラスの一部が変更できるかどうか、または編集フォームのテンプレートを変更する必要があるかどうかは疑問です。
これも解決しますか。あなたは答えを見つけましたか? – Sparrowcide
「/ delete」エンドポイントを記述してボタンをテンプレートに追加する必要がありました。今すぐ回答を投稿する。 –