Django中CharField的choices

  本来以为是比较难的问题,试了一堆记忆中的属性什么的,就是不认,后来骚扰了一下limodou才了解到原来是个这么简单的方法,而且在db-api手册中也有说。诶,看东西看的不仔细,丢人了啊。说说正题吧,就用step by step的例子说吧,本来显示的是M或F,因为直接调用的是address.gender,但是如果调用addres.get_gender_display就可以显示为男或女。简单吧,我怎么就没看到呢?

This entry was posted in Happy coding. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>