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
Exception Type: TypeError
Exception Value: coercing to Unicode: need string or buffer, User found