http://blog.csdn.net/u013690521/article/details/38777213
from django.db import models from django.contrib import admin # Create your models here. class AdminUser(models.Model): loginname = models.CharField(max_length=64, unique=True, db_index=True) fullname = models.CharField(max_length=64) email = models.EmailField(max_length=64) password = models.CharField(max_length=64) url_height = models.PositiveIntegerField(default=75) url_width = models.PositiveIntegerField(default=75) admin_icon = models.ImageField(upload_to="icons", height_field=‘url_height‘, width_field=‘url_width‘) admin.site.register(AdminUser)
其中ImageFiled的两个参数height_field和width_field指定的是两个字段,它们的作用是自动填充字段
也就是说当上传图片后,它就会自动获取图片的高和宽,并存入url_height和url_width字段
时间: 2024-11-03 05:21:33