zoukankan      html  css  js  c++  java
  • django后台admin管理布局

    在model模块里设置

    class pc_info(models.Model):
      ip = models.CharField(max_length=64)
      sn = models.CharField(max_length=64)
      addr = models.CharField(max_length=64)
      room_num = models.CharField(max_length=64)
      pc_type = models.CharField(max_length=64)
      brand = models.CharField(max_length=64)
      chest_num = models.CharField(max_length=64)
      disk_num = models.CharField(max_length=64)
      disk_pn = models.CharField(max_length=64)
      single_disk_size = models.CharField(max_length=64)
      out_ip = models.CharField(max_length=64)
      comment = models.CharField(max_length=64)

    def __str__(self):                            #定义标题
      return self.ip
    def address(self):                            #定义标题
      return self.addr

    address.short_description = '地区'  #后排管理显示中文标题

    address.admin_order_field = 'addr'  #可以点击定义的addr的标题排序

    在admin.py里设置

    from cmdb.models import pc_info      #从models模块里导入表的类名
    # Register your models here.

    class pc_infoAdmin(admin.ModelAdmin):
      list_per_page = 15                                      #一页显示15行数据
      list_display = ['ip', 'address', 'room_num']   #要显示的标题

      action_on_bottom = True                 #删除选项放在底部

      action_on_top = False         #删除顶部的删除栏

      list_filter = ['ip']                #列表右侧过滤栏

      search_fields =['ip', 'addr']         #查找栏(写上可以按照什么查找)
    admin.site.register(pc_info, pc_infoAdmin)      #注册

  • 相关阅读:
    SpringBoot和SpringCould的关系
    MyBatis全局配置文件头
    MyBatis的SQL映射文件头
    MyBatis 驼峰式配置 yml配置
    频率组件
    序列化和反序列化
    生成器面试题
    序列化组件
    进程间通信IPC机制
    信号量、event事件和线程queue
  • 原文地址:https://www.cnblogs.com/fengzi7314/p/9636483.html
Copyright © 2011-2022 走看看