欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

dashboard 增加编辑按钮

程序员文章站 2022-03-18 13:37:13
...
用到其他目录下的文件,用到workflows

1.tables.py添加如下内容

from openstack_dashboard.dashboards.project.instances \
    import tables as project_tables
class AdminEditInstance(project_tables.EditInstance):
    url = "horizon:mydashboard:mypanel:update"

row_actions = (CreateSnapshotAction,DeleteSnapshotAction,AdminEditInstance)


2.urls.py
url(r'^(?P<instance_id>[^/]+)/update/$',
            views.AdminUpdateView.as_view(),
            name='update')


3.views.py
from openstack_dashboard.dashboards.project.instances import views as viewss  //区别其他的views
from openstack_dashboard.dashboards.project.instances.workflows \
    import update_instance
class AdminUpdateView(viewss.UpdateView):
    workflow_class = update_instance.AdminUpdateInstance
    success_url = reverse_lazy("horizon:mydashboard:mypanel:index")