Django中ImageField的使用

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

上一篇:Java多线程系列--“JUC集合”03之 CopyOnWriteArraySet


下一篇:JDBC连接数据库报错:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. ......