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字段