0
在我的UserProfile模型中,我只是在這裏添加了django-imagekit和縮略圖字段來爲我創建縮略圖,但是當我運行./manage.py makemigrations時,django說沒有改變檢測到,並且縮略圖字段未添加到數據庫。模型中的字段未被識別爲遷移
這是我的代碼。我正在使用Python 3.4和Django 1.7:
from django.db import models
from django.contrib.auth.models import User
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFill
from phonenumber_field.modelfields import PhoneNumberField
def get_upload_file_name(instance, filename):
return '/'.join([instance.user_auth.email, filename])
# Create your models here.
class UserProfile(models.Model):
user_auth = models.OneToOneField(User, related_name="profile")
phone = PhoneNumberField(null=True, blank=True, verbose_name="Phone number")
birth_date = models.DateField(verbose_name="Date of Birth", null=True, blank=True)
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
('N', 'Not Specified'),
)
gender = models.CharField(
max_length=1, choices=GENDER_CHOICES, blank=False, default='N', verbose_name='Gender')
pic = models.ImageField(upload_to=get_upload_file_name,
width_field="width_field",
height_field="height_field",
null=True,
blank=True,
verbose_name="Profile Picture"
)
height_field = models.PositiveIntegerField(null=True, default=0)
width_field = models.PositiveIntegerField(null=True, default=0)
thumbnail = ImageSpecField(source='pic',
processors=[ResizeToFill(120,120)],
format='JPEG',
options={'quality': 60})
謝謝。我想我應該更仔細地閱讀文檔。 – rfj001 2014-10-11 20:23:34