标签:orm pytho only idt max lis turn min queryset
nid = models.AutoField(primary_key=True,verbose_name=‘序号‘) ww = models.TextField(verbose_name=‘ID‘) tp = models.CharField(max_length=32,verbose_name=‘举报类型‘) phone = models.CharField(max_length=32,verbose_name=手机号‘) pic = models.BinaryField(verbose_name=‘凭证‘) beizhu = models.TextField(default=0,verbose_name=‘备注‘) def image_data(self): pic=str(base64.b64encode(self.pic))[1:].strip("‘") return format_html( ‘<img src="data:image/png;base64,{}" width="50px" class="changepic"/>‘, pic, ) image_data.short_description = "凭证" 字段名称 class Meta: verbose_name_plural = ‘审核‘ # 指定在admin管理界面中显示的名称 去掉plural会出现s
数据表名称修改方法
app.py 下面创建
class HomeConfig(AppConfig):
name = ‘home‘
verbose_name = ‘数据审核及用户授权‘
然后再__init__.py 下面
default_app_config = ‘home.apps.HomeConfig‘
这样就能正常显示了
admin
class jb_shAdmin(admin.ModelAdmin):
list_display = (‘nid‘,‘name‘,‘phone‘) #后台页面展示的数据字段
readonly_fields = (‘pict‘,) #只读数据
ordering = (‘nid‘,) #排序 加‘-’号代表倒叙
actions = [‘audit_pass‘, ‘audit_failed‘] #操作
def audit_pass(self,request,queryset):
audit_pass.short_description = "审核通过" #操作命名
标签:orm pytho only idt max lis turn min queryset
原文地址:https://www.cnblogs.com/jxfy/p/12541968.html