class UserProfile models Model user models ForeignKey User unique True

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True)
location = models.CharField(u"Откуда",max_length = 60, blank = True)
avatar = models.ImageField(blank = True, upload_to="avatars/", help_text=u'Максимальный объём %s Кб. Изображение будет преобразовано к размеру %ix%i' % (settings.MAX_AVATAR_FILE_SIZE, settings.AVATAR_SIZE[0], settings.AVATAR_SIZE[1]))
balance = models.FloatField(max_length = 10, blank=True, null = True)
sex = models.CharField(u'Пол', max_length=1, choices=(('m', 'Мужской'), ('f', 'Женский')), blank=True, null=True)
key = models.CharField(max_length = 40, blank=True)
key_expires = models.DateTimeField(blank=True, null=True)
def __unicode__(self):
return self.user.username + '`s profile'
#в settings.py
MAX_AVATAR_FILE_SIZE = 24 #Kb
AVATAR_SIZE = (65, 65)