开发者

How can I change name of option in django select box

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜