xadmin的部分插件的使用及bug修改

鄙人初出茅庐,请各位前辈多指教。

plugs应用:

1.ordering = [‘-aaa’,……]   排序,前面加‘-’表示倒序

2.readonly_fields = [‘aaa’,……] 只读字段,不可编辑

3.exclude = [‘aaa’,……]   隐藏字段,与只读字段冲突,只有一种生效

4.relfied_style  =’fk-ajax’  设置当前模型在其关联字段修改添加时可搜索,例如a关联了b,b添加了该设置则a添加或者修改时关联的字段可以搜索。

5.hidden_menu = True  # 设置不显示此模块菜单

6.list_editable = [‘aaa’,……]  直接在当前字段列表页便可以修改,不用点进详情页面

7.refresh_times = [3,5……] 设置列表页刷新时间可选

8.style_fields = {“fields”:”style”}   指明某字段的style样式

9.batch_fields=(‘somefield’) actions=[BatchChangeAction,] 记得BatchChangeAction存在于batch插件中,记得导入使用。

10.model_icon = 'xxxx' 其中xxxx可以去http://fontawesome.dashgame.com/看详情,将黄色框中的替换xxxx就可以了,当然得      确保你的版本是最新的才用得了最新的图标。

      

修改xadminBUG:

1.user修改密码的form bug

Bug

不能传入含变量的路径则修改成固定的:

当bug被修改后adminx就不需要重新注册userprofile了
点击表单过后就不会找不到页面了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Django Xadmin 的列表视图中添加自定义按钮,可以使用 Xadmin 的 `ButtonPlugin` 插件。 以下是添加自定义按钮的步骤: 1. 创建一个 `ButtonPlugin` 子类,例如: ```python from xadmin.plugins.utils import get_context_dict from xadmin.views import BaseAdminPlugin, ListAdminView class MyButtonPlugin(BaseAdminPlugin): # 定义按钮的图标和名称 my_btn_icon = 'fa fa-plus' my_btn_name = 'My Button' # 在页面右上角添加按钮 def get_context(self, __): context = get_context_dict(__) context['my_button_html'] = self.get_my_button_html() return context # 构建按钮的 HTML def get_my_button_html(self): return '<a class="btn btn-primary" href="#">' \ '<i class="{}"></i> {}</a>'.format(self.my_btn_icon, self.my_btn_name) ``` 2. 将 `ButtonPlugin` 子类添加到 `ListAdminView` 中: ```python class MyListAdminView(ListAdminView): # ... # 注册自定义按钮插件 plugin_my_button = MyButtonPlugin # ... ``` 3. 在模板中添加按钮的 HTML: ```html {% extends "xadmin/base_site.html" %} {% load static %} {% block content %} {{ block.super }} <div class="row-fluid"> <div class="span12"> <div class="widget-box"> <div class="widget-title"> <h5>{{ title }} List</h5> <div class="buttons"> {{ my_button_html }} <!-- 添加自定义按钮的 HTML --> </div> </div> <div class="widget-content nopadding"> <!-- ... --> </div> </div> </div> </div> {% endblock %} ``` 这样,在列表视图页面的右上角就会出现一个名为 My Button 的自定义按钮。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值