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

相关文章:

  • 2021-07-06
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-09-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
相关资源
相似解决方案