Форум сайта python.su
Разшыряю стандартную модель юзера через AUTH_PROFILE_MODULE
from django.db import models
from django.contrib.auth.models import User
class Profile(models.Model):
GENDER_CHOICES = (
('M', u'Male'),
('F', u'Female'),
)
user = models.ForeignKey(User, unique=True)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
birthday = models.DateField()
city = models.ForeignKey('City', blank=True)
friends = models.ManyToManyField('self', blank=True)
ratio = models.IntegerField(default=0)
def __unicode__(self):
return self.user
class City(models.Model):
name = models.CharField(max_length=255)
region = models.ForeignKey('Region')
def __unicode__(self):
return '%s (%s)' % (self.name, self.region)
class Region(models.Model):
name = models.CharField(max_length=200)
def __unicode__(self):
return self.name
Офлайн
Поменяйте
def __unicode__(self):
return self.user
def __unicode__(self):
from django.utils.encoding import force_unicode
return force_unicode(self.user)
Офлайн