I got 2 models
class Category(models.Model):
name = mod开发者_JAVA百科els.CharField(max_length=30, unique=True)
class Post(models.Model):
......
category = models.ForeginKey(Category)
........
And when I create a form, in select box i got options "Category object", but i would like to display name of category, i am sure it's basic, just missed it in doc's :C
class Category(models.Model):
name = models.CharField(max_length=30, unique=True)
def __unicode__(self):
return self.name
精彩评论