Nenhuma Descrição

admin.py 862B

    # -*- coding: utf-8 -*- from django.contrib import admin from django.contrib.auth.hashers import make_password from account.models import LensmanInfo from utils.uuid_utils import curtailUUID class LensmanInfoAdmin(admin.ModelAdmin): readonly_fields = ('lensman_id', 'encryption', ) list_display = ('lensman_id', 'name', 'sex', 'phone', 'location', 'proportion', 'status', 'created_at', 'updated_at') search_fields = ('name', 'phone', 'location') list_filter = ('sex', 'status') def save_model(self, request, obj, form, change): if not obj.lensman_id: obj.lensman_id = curtailUUID(LensmanInfo, 'lensman_id') if obj.password: obj.encryption = make_password(obj.password, None, 'pbkdf2_sha256') obj.password = None obj.save() admin.site.register(LensmanInfo, LensmanInfoAdmin)