http://my.oschina.net/zhajiang/blog/56814
meta嵌套类
class Person(models.Model):
first=models.CharField(max_length=100)
last=models.CharField(max_length=100)
middle=models.CharField(max_length=100,blank=True)
class Meta:
#the proper way to oder people,assuming a Last,First M. style of display
ordering=['last','first','middle']
#Here we encode the fact that we can't have a person with a 100%
#identical name. Of course,in real life,we could,but we'll pretend
#this is an ideal worl
unique_together=['first','last','middle']
#Django's default pluralization is simply to add 's' to the end:that
#doesn't work here.
verbose_name_plural="people"
Meta 类主要处理模型各种元数据的使用和显示:查询数据表示的排序,数据表的名字等。
django-chinese-docs-16/django-chinese-docs-16-latest/ref/models/options.html
media嵌套类
Assets as a static definition
The easiest way to define assets is as a static definition. Using this method, the declaration is an inner Media class. The properties of the inner class define the requirements.
Here’s a simple example:
This code defines a CalendarWidget, which will be based on TextInput. Every time the CalendarWidget is used on a form, that form will be directed to include the CSS file pretty.css, and the JavaScript filesanimations.js and actions.js.
This static definition is converted at runtime into a widget property named media. The list of assets for a CalendarWidget instance can be retrieved through this property:
---django-chinese-docs-16/django-chinese-docs-16-latest/topics/forms/media.html