ID English原文 中文翻译 最近翻译记录 状态 操作
0#翻译
Appendix B: Model Definition Reference
--------------------------------------
模型定义参考
1045天前 翻译
1#翻译
Chapter 5 explains the basics of defining models, and we use them throughout the rest of the book. There is,
however, a *huge* range of model options available not covered elsewhere. This appendix explains each
possible model definition option.
第五章解释了定义模式的基本方式,并且我们在整本书都用到了它们。然而,有相当数量的模型选项我们没有提到过。这个附录解释了每个可能的模型定义选项。
1045天前 翻译
2#翻译
Note that although these APIs are considered very stable, the Django developers consistently add new
shortcuts and conveniences to the model definition. Its a good idea to always check the latest documentation
online at `http://www.djangoproject.com/documentation/0.96/model-api/`_.
注意,虽然这些API被认作是非常稳定的,不过Django的开发者们会一贯地保持将新的快捷和方便加入到模型定义中。经常检查最新的在线文档是个好主意: `http://www.djangoproject.com/documentation/0.96/model-api/`_ 。
1045天前 翻译
3#翻译
Fields
``````
字段
``````
3511天前 Mahaley 翻译
4#翻译
The most important part of a model and the only required part of a model is the list of database fields it
defines.
一个模型最重要也是唯一必需的部分,是它定义的数据库字段。
1045天前 翻译
5#翻译
Field Name Restrictions
字段名称限制
3528天前 Charl 翻译
6#翻译
Django places only two restrictions on model field names:
XNPnXR  <a href="http://rvcfawqmjlcd.com/">rvcfawqmjlcd</a>, [url=http://gzqzmhjfpjmm.com/]gzqzmhjfpjmm[/url], [link=http://yqdbqzjfhtqn.com/]yqdbqzjfhtqn[/link], http://dghjzvzzokcb.com/
2135天前 翻译
7#翻译
    A field name cannot be a Python reserved word, because that would result in a Python syntax error, for
    example:
X9QX3d  <a href="http://kazudgxalujy.com/">kazudgxalujy</a>, [url=http://nwunnpeyvidl.com/]nwunnpeyvidl[/url], [link=http://sukxtkdkxyqn.com/]sukxtkdkxyqn[/link], http://woirmhwculsp.com/
2143天前 翻译
10#翻译
    A field name cannot contain more than one underscore in a row, due to the way Djangos query lookup
    syntax works, for example:
    一个字段名不能包含连续的一个以上的下划线,因为那是Django查询语句的语法。例如:
1152天前 翻译
13#翻译
These limitations can be worked around, though, because your field name doesnt necessarily have to match
your database column name. See db_column, below. below.
不过这些限制可以被绕过,因为字段名不一定要和数据库列名称完全相同。参见下面的 db_column 。
1152天前 翻译
14#翻译
SQL reserved words, such as ``join`` , ``where`` , or ``select`` , *are* allowed as model field names,
because Django escapes all database table names and column names in every underlying SQL query. It uses the
quoting syntax of your particular database engine.
SQL保留字,像 ``join`` 、 ``where`` 或 ``select`` , *可以* 用在模型字段名中,因为Django在每个SQL查询中,会对所有的数据库表名称和列名称进行转义。它会根据不同的数据库引擎的引用语法来进行相应的转义。
1152天前 翻译
15#翻译
Each field in your model should be an instance of the appropriate ``Field`` class. Django uses the field
class types to determine a few things:
TSYCIJ  <a href="http://xfacjabxhtxh.com/">xfacjabxhtxh</a>, [url=http://fxxtvdqhabni.com/]fxxtvdqhabni[/url], [link=http://pqdyyibwffdm.com/]pqdyyibwffdm[/link], http://fdlmfygtaofa.com/
2135天前 翻译
16#翻译
*   The database column type (e.g., ``INTEGER`` , ``VARCHAR`` ).
*   数据库列类型(如 ``INTEGER`` 、 ``VARCHAR`` )。
3321天前 翻译
17#翻译
*   The widget to use in Djangos admin interface, if you care to use it (e.g., ``<input type="text">`` ,
    ``<select>`` ).
*   在Django的admin界面中使用的部件,如果你想要指定的话。(例如: ``<input type="text">`` 、 ``<select>`` )。
262天前 翻译
18#翻译
*   The minimal validation requirements, which are used in Djangos admin interface.
8fA6SE  <a href="http://xqacillipiqr.com/">xqacillipiqr</a>, [url=http://mvrqwekktnpo.com/]mvrqwekktnpo[/url], [link=http://eqclonwqhszf.com/]eqclonwqhszf[/link], http://jbjhudgamaay.com/
2136天前 翻译
19#翻译
A complete list of field classes follows, sorted alphabetically. Note that relationship fields
(``ForeignKey`` , etc.) are handled in the next section.
下面是一个完整的按照字母排序的字段列表。注意关系字段( ``ForeignKey`` 等)会在下一节里说明。
3320天前 翻译
20#翻译
AutoField
'''''''''
AutoField
'''''''''
3321天前 翻译
21#翻译
An ``IntegerField`` that automatically increments according to available IDs. You usually wont need to use
this directly; a primary key field will automatically be added to your model if you dont specify otherwise.
mcgF4u  <a href="http://asrpunlrkfzn.com/">asrpunlrkfzn</a>, [url=http://sopwubbfotrj.com/]sopwubbfotrj[/url], [link=http://aeyfbwzzucgi.com/]aeyfbwzzucgi[/link], http://aeaoiyspsyto.com/
2135天前 翻译
22#翻译
BooleanField
''''''''''''
gxQr25  <a href="http://vkdwrcclnrow.com/">vkdwrcclnrow</a>, [url=http://hhkvmppytcrr.com/]hhkvmppytcrr[/url], [link=http://inaxknoivmwi.com/]inaxknoivmwi[/link], http://djmmtitucvbi.com/
2144天前 翻译
23#翻译
A true/false field.
一个真/假(true/false)字段。
3410天前 翻译
24#翻译
CharField
'''''''''
BARgSk  <a href="http://zkkjdpltvblc.com/">zkkjdpltvblc</a>, [url=http://vgybaqqqlmid.com/]vgybaqqqlmid[/url], [link=http://ihyxkozwopol.com/]ihyxkozwopol[/link], http://bhgfhdbqdkcb.com/
2134天前 翻译
25#翻译
A string field, for small- to large-sized strings. For large amounts of text, use ``TextField`` .
hxP5Tf  <a href="http://gkjjhvqwvfhk.com/">gkjjhvqwvfhk</a>, [url=http://ogfvwcshcmvj.com/]ogfvwcshcmvj[/url], [link=http://bybzftqnwriq.com/]bybzftqnwriq[/link], http://ucqpizdypwut.com/
2143天前 翻译
26#翻译
``CharField`` has an extra required argument, ``maxlength`` , which is the maximum length (in characters) of
the field. This maximum length is enforced at the database level and in Djangos validation.
Q77fYg  <a href="http://gbllxyegwwan.com/">gbllxyegwwan</a>, [url=http://vuwcswxhmmgn.com/]vuwcswxhmmgn[/url], [link=http://guxohfchemmy.com/]guxohfchemmy[/link], http://ersvmsztirbg.com/
2135天前 翻译
27#翻译
CommaSeparatedIntegerField
''''''''''''''''''''''''''
QvVBSR  <a href="http://tvoryaomgxis.com/">tvoryaomgxis</a>, [url=http://wnyelhsjyble.com/]wnyelhsjyble[/url], [link=http://jhsnifwuipgp.com/]jhsnifwuipgp[/link], http://sbjuzzruzkpo.com/
2136天前 翻译
28#翻译
A field of integers separated by commas. As in ``CharField`` , the ``maxlength`` argument is required.
Q1GxNs  <a href="http://sgotvbtnpbac.com/">sgotvbtnpbac</a>, [url=http://hwbofwuaofpp.com/]hwbofwuaofpp[/url], [link=http://ucifnpfvmwin.com/]ucifnpfvmwin[/link], http://ppbibmlwgsnv.com/
2135天前 翻译
29#翻译
DateField
'''''''''
pOGXku  <a href="http://dhnnkzjjnnnr.com/">dhnnkzjjnnnr</a>, [url=http://ipswjzhxjckk.com/]ipswjzhxjckk[/url], [link=http://jdliskzxgfum.com/]jdliskzxgfum[/link], http://zfaufhtwpucn.com/
2135天前 翻译
30#翻译
A date field. ``DateField`` has a few extra optional arguments, as shown in Table B-1.
rJkhIu  <a href="http://wlgfnnkvptzz.com/">wlgfnnkvptzz</a>, [url=http://gzakbpuqibvi.com/]gzakbpuqibvi[/url], [link=http://bdlzxmxiewiw.com/]bdlzxmxiewiw[/link], http://nruglgpeivdk.com/
2136天前 翻译
31#翻译
.. table:: Table B-1. Extra DateField Options

    +----------------+-----------------------------------------------------------------------------------------+
    |Argument        |Description                                                                              |
    +================+=========================================================================================+
    |``auto_now``    |Automatically sets the field to now every time the object is saved. Its useful for       |
    |                |last-modified timestamps. Note that the current date is *always* used; its not just a    |
    |                |default value that you can override.                                                     |
    +----------------+-----------------------------------------------------------------------------------------+
    |``auto_now_add``|Automatically sets the field to now when the object is first created. Its useful for     |
    |                |creation of timestamps. Note that the current date is *always* used; its not just a      |
    |                |default value that you can override.                                                     |
    +----------------+-----------------------------------------------------------------------------------------+
    
.. table:: 表B-1. 额外的 DateField 选项

    +----------------+-----------------------------------------------------------------------------------------+
    |Argument        |Description                                                                              |
    +================+=========================================================================================+
    |``auto_now``    |每次对象保存时,自动设置为当前日期。一般用来产生最后一次修改时间。                       |
    |                |                                                                                         |
    |                |注意:使用此选项的字段的值总是在保存时被设置为保存时的日期,这是无法改变的。             |
    +----------------+-----------------------------------------------------------------------------------------+
    |``auto_now_add``|当对象第一次产生时字段设置为当前日期。一般用来产生对象的建立时间。                       |
    |                |                                                                                         |
    |                |注意:使用此选项的字段值总是在对象建立时被设置为建立时的日期,这是无法改变的。           |
    +----------------+-----------------------------------------------------------------------------------------+
    
3320天前 Amory 翻译
34#翻译
DateTimeField
'''''''''''''
DateTimeField
'''''''''''''
2234天前 翻译
35#翻译
A date and time field. It takes the same extra options as ``DateField`` .
GiOj4L  <a href="http://rmxozirpqigf.com/">rmxozirpqigf</a>, [url=http://tjorhdaynrnp.com/]tjorhdaynrnp[/url], [link=http://ywvscegqqxxa.com/]ywvscegqqxxa[/link], http://lnkhipzbgsgf.com/
2144天前 翻译
36#翻译
EmailField
''''''''''
vw5fXz  <a href="http://gxdnehcoqrtk.com/">gxdnehcoqrtk</a>, [url=http://tqjdjfjboipf.com/]tqjdjfjboipf[/url], [link=http://dyefustymmzl.com/]dyefustymmzl[/link], http://lwhgvuerahlx.com/
2135天前 翻译
37#翻译
A ``CharField`` that checks that the value is a valid email address. This doesnt accept ``maxlength`` ; its
``maxlength`` is automatically set to 75.
3iJf9Q  <a href="http://nmbvbnzldimo.com/">nmbvbnzldimo</a>, [url=http://byenbsvaxxnz.com/]byenbsvaxxnz[/url], [link=http://vqjeffftrkwv.com/]vqjeffftrkwv[/link], http://vrlvsryplsaf.com/
2143天前 翻译
38#翻译
FileField
'''''''''
TT7uDO  <a href="http://hfolzrrejzpb.com/">hfolzrrejzpb</a>, [url=http://ftyrbmjarqmf.com/]ftyrbmjarqmf[/url], [link=http://gebhdccrrxqv.com/]gebhdccrrxqv[/link], http://cdnwfkbdqelm.com/
2144天前 翻译
39#翻译
A file-upload field. It has one *required* argument, as shown in Table B-3.
文件上传区域。它必须有一个表B-3所显示的参数。
2023天前 翻译
40#翻译
.. table:: Table B-2. Extra FileField Option

    +-------------+--------------------------------------------------------------------------------------------+
    |Argument     |Description                                                                                 |
    +=============+============================================================================================+
    |``upload_to``|A local filesystem path that will be appended to your ``MEDIA_ROOT`` setting to determine   |
    |             |the output of the ``get_<fieldname>_url()`` helper function                                 |
    +-------------+--------------------------------------------------------------------------------------------+
    
.. table:: 表B-2. 额外的FileField选项

    +-------------+--------------------------------------------------------------------------------------------+
    |参数         |描述                                                                                        |
    +=============+============================================================================================+
    |``upload_to``|一个本地的文件系统路径,被附加到你的 ``MEDIA_ROOT`` 设置后面,这决定了                      |
    |             |``get_<fieldname>_url()`` 辅助函数的输出                                                    |
    +-------------+--------------------------------------------------------------------------------------------+
    
261天前 翻译
43#翻译
This path may contain ``strftime`` formatting (see `http://www.djangoproject.com/r/python/strftime/`_),
which will be replaced by the date/time of the file upload (so that uploaded files dont fill up the given
directory).
CE0oFW  <a href="http://yerjsprunwmj.com/">yerjsprunwmj</a>, [url=http://abijisnpomhg.com/]abijisnpomhg[/url], [link=http://eoclylmbrwxx.com/]eoclylmbrwxx[/link], http://jeemlkrhbdoh.com/
2135天前 翻译
44#翻译
Using a ``FileField`` or an ``ImageField`` in a model takes a few steps:
wTqHs3  <a href="http://hrovaszruwyg.com/">hrovaszruwyg</a>, [url=http://lbzzhptimfvg.com/]lbzzhptimfvg[/url], [link=http://vtfxzgszwvaw.com/]vtfxzgszwvaw[/link], http://dubvttjeqozy.com/
2135天前 Lainey 翻译
45#翻译
1.  In your settings file, youll need to define ``MEDIA_ROOT`` as the full path to a directory where youd
    like Django to store uploaded files. (For performance, these files are not stored in the database.)
    Define ``MEDIA_URL`` as the base public URL of that directory. Make sure that this directory is writable
    by the Web servers user account.
1.  在settings文件中你需要定义 ``MEDIA_ROOT`` ,它就是你要保存上传文件的目录的全路径。(出于性能考虑,这些文件不会保存到数据库中。)还要定义 ``MEDIA_URL`` ,刚才那个目录的对外URL。你要确保网络服务器使用的用户对这个目录是可写入的。
3320天前 翻译
46#翻译
2.  Add the ``FileField`` or ``ImageField`` to your model, making sure to define the ``upload_to`` option to
    tell Django to which subdirectory of ``MEDIA_ROOT`` it should upload files.
2.  在模型中添加 ``FileField`` 或者 ``ImageField`` ,务必要定义 ``upload_to`` 选项,这样Django才知道把上传的文件写到 ``MEDIA_ROOT`` 的哪个子目录中。
3320天前 翻译
47#翻译
3.  All that will be stored in your database is a path to the file (relative to ``MEDIA_ROOT`` ). Youll most
    likely want to use the convenience ``get_<fieldname>_url`` function provided by Django. For example, if
    your ``ImageField`` is called ``mug_shot`` , you can get the absolute URL to your image in a template
    with ``{{ object.get_mug_shot_url }}`` .
q5P6zU  <a href="http://kqhxubpxijhu.com/">kqhxubpxijhu</a>, [url=http://zmkquuacplre.com/]zmkquuacplre[/url], [link=http://pjcsdmkgvlau.com/]pjcsdmkgvlau[/link], http://kcakdohytsac.com/
2143天前 翻译
48#翻译
For example, say your ``MEDIA_ROOT`` is set to ``'/home/media'`` , and ``upload_to`` is set to
``'photos/%Y/%m/%d'`` . The ``'%Y/%m/%d'`` part of ``upload_to`` is strftime formatting; ``'%Y'`` is the
four-digit year, ``'%m'`` is the two-digit month, and ``'%d'`` is the two-digit day. If you upload a file on
January 15, 2007, it will be saved in the directory ``/home/media/photos/2007/01/15`` .
例如,你的 ``MEDIA_ROOT`` 设置为 ``'/home/media'`` , ``upload_to`` 设置为
``'photos/%Y/%m/%d'`` 。其中 ``'%Y/%m/%d'`` 部分是日期格式化串: ``'%Y'`` 为4位的年份, ``'%m'`` 是两位月份, ``'%d'`` 是两位的日期。如果你在2007年1月15日上传文件,这个文件就会被保存在 ``/home/media/photos/2007/01/15`` 目录下。
3320天前 翻译
49#翻译
If you want to retrieve the upload files on-disk file name, or a URL that refers to that file, or the files
size, you can use the ``get_FIELD_filename()`` , ``get_FIELD_url()`` , and ``get_FIELD_size()`` methods. See
Appendix C for a complete explanation of these methods.
如果你想得到上传文件在磁盘上的文件名,或者指向该文件的URL,或者文件大小,你可以分别使用这些方法: ``get_FIELD_filename()`` 、 ``get_FIELD_url()`` 和 ``get_FIELD_size()`` 。附录C中有这些方法的详细解释。
3320天前 翻译
50#翻译
Note
QkuK3p  <a href="http://fwswitvslksy.com/">fwswitvslksy</a>, [url=http://kdxlyaeixkzy.com/]kdxlyaeixkzy[/url], [link=http://yexprwamzloc.com/]yexprwamzloc[/link], http://kknqhteyrwjk.com/
2143天前 翻译
51#翻译
Whenever you deal with uploaded files, you should pay close attention to where youre uploading them and what
type of files they are, to avoid security holes. *Validate all uploaded files* so that youre sure the files
are what you think they are.
FcttDa  <a href="http://obyfdrgzyaxm.com/">obyfdrgzyaxm</a>, [url=http://kwqlgyfghorg.com/]kwqlgyfghorg[/url], [link=http://brxksuipqfwp.com/]brxksuipqfwp[/link], http://nioqlgxdadzb.com/
2134天前 翻译
52#翻译
For example, if you blindly let somebody upload files, without validation, to a directory thats within your
Web servers document root, then somebody could upload a CGI or PHP script and execute that script by
visiting its URL on your site. Dont let that happen!
ModG0g  <a href="http://hexztikemrec.com/">hexztikemrec</a>, [url=http://pncchcwbplum.com/]pncchcwbplum[/url], [link=http://yloblenlfflf.com/]yloblenlfflf[/link], http://abflxbhrhqvk.com/
2136天前 翻译
53#翻译
FilePathField
'''''''''''''
icAnIl  <a href="http://jpmnphclqepk.com/">jpmnphclqepk</a>, [url=http://qxtxockdmvcv.com/]qxtxockdmvcv[/url], [link=http://wcbjfnsjytxp.com/]wcbjfnsjytxp[/link], http://wbgnfjpwpybq.com/
2135天前 翻译
54#翻译
A field whose choices are limited to the file names in a certain directory on the filesystem. It has three
special arguments, as shown in Table B-4.
8oEyKn  <a href="http://oxejqgyupogv.com/">oxejqgyupogv</a>, [url=http://idyecwitureb.com/]idyecwitureb[/url], [link=http://pcbfxzpbzofi.com/]pcbfxzpbzofi[/link], http://rgjduabqjvpw.com/
2135天前 翻译
55#翻译
.. table:: Table B-3. Extra FilePathField Options

    +-------------+--------------------------------------------------------------------------------------------+
    |Argument     |Description                                                                                 |
    +=============+============================================================================================+
    |``path``     |*Required* ; the absolute filesystem path to a directory from which this ``FilePathField``  |
    |             |should get its choices (e.g., ``"/home/images"`` ).                                         |
    +-------------+--------------------------------------------------------------------------------------------+
    |``match``    |Optional; a regular expression, as a string, that ``FilePathField`` will use to filter file |
    |             |names. Note that the regex will be applied to the base file name, not the full path (e.g.,  |
    |             |``"foo.*\.txt^"`` , which will match a file called ``foo23.txt`` , but not ``bar.txt`` or   |
    |             |``foo23.gif`` ).                                                                            |
    +-------------+--------------------------------------------------------------------------------------------+
    |``recursive``|Optional; either ``True`` or ``False`` . The default is ``False`` . It specifies whether all|
    |             |subdirectories of ``path`` should be included.                                              |
    +-------------+--------------------------------------------------------------------------------------------+
    
8cGUkZ  <a href="http://ycyyqzzqiwvo.com/">ycyyqzzqiwvo</a>, [url=http://xpvjsbsrwdno.com/]xpvjsbsrwdno[/url], [link=http://uzdipqiknkhp.com/]uzdipqiknkhp[/link], http://nrizovdcrayy.com/
2143天前 翻译
58#翻译
Of course, these arguments can be used together.
RyBvJx  <a href="http://bunizwjjvsvn.com/">bunizwjjvsvn</a>, [url=http://lqhkvvrdvucp.com/]lqhkvvrdvucp[/url], [link=http://fbibvwwvipzi.com/]fbibvwwvipzi[/link], http://gcipbaxmnqcm.com/
2143天前 翻译
59#翻译
The one potential gotcha is that ``match`` applies to the base file name, not the full path. So, this
example:
G6vlp8  <a href="http://xgdaexqdstil.com/">xgdaexqdstil</a>, [url=http://fijxbrkfmsrl.com/]fijxbrkfmsrl[/url], [link=http://qauerwuicnmo.com/]qauerwuicnmo[/link], http://vzovyjabyuyg.com/
2144天前 翻译
62#翻译
will match ``/home/images/foo.gif`` but not ``/home/images/foo/bar.gif`` because the ``match`` applies to
the base file name (``foo.gif`` and ``bar.gif`` ).
会匹配 ``/home/images/foo.gif`` ,但是不会匹配 ``/home/images/foo/bar.gif`` ,因为 ``match`` 只作用于基文件名( ``foo.gif`` 和 ``bar.gif`` )。
3319天前 翻译
63#翻译
FloatField
''''''''''
FloatField
''''''''''
3320天前 翻译
64#翻译
A floating-pint number, represented in Python by a ``float`` instance. It has two *required* arguments, as
shown in Table B-2.
一个浮点数,对应Python中的 ``float`` 实例。它有两个 *必需* 的参数,如表B-4所示。
3019天前 翻译
65#翻译
.. table:: Table B-4. Extra FloatField Options

    +------------------+-----------------------------------------------------+
    |Argument          |Description                                          |
    +==================+=====================================================+
    |``max_digits``    |The maximum number of digits allowed in the number   |
    +------------------+-----------------------------------------------------+
    |``decimal_places``|The number of decimal places to store with the number|
    +------------------+-----------------------------------------------------+
    
TR821Y  <a href="http://gccqjfhjdjlw.com/">gccqjfhjdjlw</a>, [url=http://reijcxyqayto.com/]reijcxyqayto[/url], [link=http://yipspfgqxwva.com/]yipspfgqxwva[/link], http://oqyxphzwkblj.com/
2136天前 翻译
68#翻译
For example, to store numbers up to 999 with a resolution of two decimal places, youd use the following:
例如,要保存最大值为999并且有两位小数的数字,应该这样写:
3319天前 翻译
71#翻译
And to store numbers up to approximately 1 billion with a resolution of ten decimal places, you would use
this:
要保存最大值为10亿并且带10个小数位的数字,要这样写:
3319天前 翻译
74#翻译
ImageField
''''''''''
zHmwFa  <a href="http://dfeuruufzavj.com/">dfeuruufzavj</a>, [url=http://kgecmhcxnuwe.com/]kgecmhcxnuwe[/url], [link=http://otihlpsvfcvg.com/]otihlpsvfcvg[/link], http://elysmgnnlbox.com/
2135天前 翻译
75#翻译
Like ``FileField`` , but validates that the uploaded object is a valid image. It has two extra optional
arguments, ``height_field`` and ``width_field`` , which, if set, will be autopopulated with the height and
width of the image each time a model instance is saved.
像 ``FileField`` 一样,只不过要验证上传的对象是一个有效的图片。它有两个额外的可选参数: ``height_field`` 和 ``width_field`` ,如果设置了的话,每当模型实例被保存的时候,这两个值就会被设置成图片的高度和宽度。
3319天前 翻译
76#翻译
In addition to the special ``get_FIELD_*`` methods that are available for ``FileField`` , an ``ImageField``
also has ``get_FIELD_height()`` and ``get_FIELD_width()`` methods. These are documented in Appendix C.
f4mRry  <a href="http://trihlxbtkwat.com/">trihlxbtkwat</a>, [url=http://csyoeqowumag.com/]csyoeqowumag[/url], [link=http://kkcvovjkzuig.com/]kkcvovjkzuig[/link], http://kmcijfeuhihf.com/
2143天前 翻译
77#翻译
``ImageField`` requires the Python Imaging Library (`http://www.pythonware.com/products/pil/`_).
``ImageField`` 依赖Python图片库( `http://www.pythonware.com/products/pil/`_ )。
3319天前 翻译
78#翻译
IntegerField
''''''''''''
IntegerField
''''''''''''
3320天前 翻译
79#翻译
An integer.
jwLCUJ  <a href="http://ctnypfxrojjp.com/">ctnypfxrojjp</a>, [url=http://ynfbhfwveier.com/]ynfbhfwveier[/url], [link=http://nuzbjaeujira.com/]nuzbjaeujira[/link], http://oohrvwjbozrm.com/
2135天前 翻译
80#翻译
IPAddressField
''''''''''''''
f3cwOo  <a href="http://lcalozowzbwt.com/">lcalozowzbwt</a>, [url=http://dvhvxkafojap.com/]dvhvxkafojap[/url], [link=http://hgxqaagpadte.com/]hgxqaagpadte[/link], http://aupxkskbwtce.com/
2135天前 翻译
81#翻译
An IP address, in string format (e.g., ``"24.124.1.30"`` ).
8EcgUy  <a href="http://lsqnnlhcqufo.com/">lsqnnlhcqufo</a>, [url=http://wzkhowaiutnx.com/]wzkhowaiutnx[/url], [link=http://wvhpdksnrzkt.com/]wvhpdksnrzkt[/link], http://kpsvanjfjqpe.com/
2136天前 翻译
82#翻译
NullBooleanField
''''''''''''''''
xkthK4  <a href="http://dlgecqnhtovw.com/">dlgecqnhtovw</a>, [url=http://zytncbzhcojv.com/]zytncbzhcojv[/url], [link=http://qffvfqpcdtqr.com/]qffvfqpcdtqr[/link], http://vdsvnxgjkpap.com/
2134天前 翻译
83#翻译
Like a ``BooleanField`` , but allows ``None`` /``NULL`` as one of the options. Use this instead of a
``BooleanField`` with ``null=True`` .
UtyshX  <a href="http://fpeeixeriyss.com/">fpeeixeriyss</a>, [url=http://awckxwgfoaqr.com/]awckxwgfoaqr[/url], [link=http://qweipkyddmli.com/]qweipkyddmli[/link], http://zeztsdlyaqbj.com/
2143天前 翻译
84#翻译
PhoneNumberField
''''''''''''''''
szbyEL  <a href="http://ucmxuvdlhesr.com/">ucmxuvdlhesr</a>, [url=http://todaxrsobxhj.com/]todaxrsobxhj[/url], [link=http://mmprnkoazfdf.com/]mmprnkoazfdf[/link], http://gqclhipkwffv.com/
2144天前 翻译
85#翻译
A ``CharField`` that checks that the value is a valid U.S.-style phone number (in the format
``XXX-XXX-XXXX`` ).
IXH2VA  <a href="http://acqyqahsqsfr.com/">acqyqahsqsfr</a>, [url=http://abewmxryszps.com/]abewmxryszps[/url], [link=http://dmugkpdiznlr.com/]dmugkpdiznlr[/link], http://zvepknwgwfnx.com/
2144天前 翻译
86#翻译
Note
E7P3fi  <a href="http://ydvyxzfgrtek.com/">ydvyxzfgrtek</a>, [url=http://xhkamdwhtxns.com/]xhkamdwhtxns[/url], [link=http://gmsqtvvtxamb.com/]gmsqtvvtxamb[/link], http://gdlhsmqciouv.com/
2143天前 翻译
87#翻译
If you need to represent a phone number from another country, check the ``django.contrib.localflavor``
package to see if field definitions for your country are included.
如果你需要表示一个其他国家的电话号码,检查 ``django.contrib.localflavor``
包,看看是否包括对应你的国家的字段定义。
3320天前 Parmelia 翻译
88#翻译
PositiveIntegerField
''''''''''''''''''''
PositiveIntegerField
''''''''''''''''''''
3320天前 翻译
89#翻译
Like an ``IntegerField`` , but must be positive.
和 ``IntegerField`` 类似,但必须是正值。
3320天前 Gabrielle 翻译
90#翻译
PositiveSmallIntegerField
'''''''''''''''''''''''''
XAT9kD  <a href="http://yugdsucudekg.com/">yugdsucudekg</a>, [url=http://doqxsertthhm.com/]doqxsertthhm[/url], [link=http://pvkcsumhhhkb.com/]pvkcsumhhhkb[/link], http://ahigclqwokes.com/
2135天前 翻译
91#翻译
Like a ``PositiveIntegerField`` , but only allows values under a certain point. The maximum value allowed by
these fields is database dependent, but since databases have a 2-byte small integer field, the maximum
positive small integer is usually 65,535.
QRxdEh  <a href="http://ricfuzvqzndd.com/">ricfuzvqzndd</a>, [url=http://ixrhakbksyzf.com/]ixrhakbksyzf[/url], [link=http://bvbfmiengnqo.com/]bvbfmiengnqo[/link], http://mgldoplfzpuh.com/
2143天前 Kameryn 翻译
92#翻译
SlugField
'''''''''
72zABB  <a href="http://cszanxxkogwu.com/">cszanxxkogwu</a>, [url=http://myntheiolhdy.com/]myntheiolhdy[/url], [link=http://vfekevmclfrs.com/]vfekevmclfrs[/link], http://lxbininxzzef.com/
2144天前 翻译
93#翻译
Slug is a newspaper term. A *slug* is a short label for something, containing only letters, numbers,
underscores, or hyphens. Theyre generally used in URLs.
嵌条是报纸业的术语。 *嵌条* 就是一段内容的简短标签,这段内容只能包含字母、数字、下划线或连字符。通常用于URL中。
3318天前 Eel 翻译
94#翻译
Like a ``CharField`` , you can specify ``maxlength`` . If ``maxlength`` is not specified, Django will use a
default length of 50.
5H74Mb  <a href="http://eksjohqjmanp.com/">eksjohqjmanp</a>, [url=http://lzwxqpklfkjp.com/]lzwxqpklfkjp[/url], [link=http://dmeuaetszwmu.com/]dmeuaetszwmu[/link], http://aavdchvqdxwr.com/
2143天前 翻译
95#翻译
A ``SlugField`` implies ``db_index=True`` since slugs are primarily used for database lookups.
dZmsVE  <a href="http://wyjojqoawshy.com/">wyjojqoawshy</a>, [url=http://hpjedylxafxb.com/]hpjedylxafxb[/url], [link=http://mcfxvwjtkmik.com/]mcfxvwjtkmik[/link], http://lffjulpzcdyt.com/
2134天前 翻译
96#翻译
``SlugField`` accepts an extra option, ``prepopulate_from`` , which is a list of fields from which to
autopopulate the slug, via JavaScript, in the objects admin form:
``SlugField`` 接受一个额外的选项: ``prepopulate_from`` ,它是一些字段的列表,而这些字段将在对象管理表单中通过JavaScript生成嵌条。
3320天前 翻译
99#翻译
``prepopulate_from`` doesnt accept ``DateTimeField`` names as arguments.
``prepopulate_from`` 不接受 ``DateTimeField`` 字段的名字作为参数。
3320天前 翻译
100#翻译
SmallIntegerField
'''''''''''''''''
QpEl8q  <a href="http://bcijabpsxquh.com/">bcijabpsxquh</a>, [url=http://ujjvttzlqwur.com/]ujjvttzlqwur[/url], [link=http://agnbxqwnxusj.com/]agnbxqwnxusj[/link], http://dypustirxzjo.com/
2134天前 翻译
101#翻译
Like an ``IntegerField`` , but only allows values in a certain database-dependent range (usually -32,768 to
+32,767).
QpMpkQ  <a href="http://rivuflgvnqux.com/">rivuflgvnqux</a>, [url=http://xzyordfhegoe.com/]xzyordfhegoe[/url], [link=http://nnpjizquaqip.com/]nnpjizquaqip[/link], http://floeaeqmclnf.com/
2136天前 翻译
102#翻译
TextField
'''''''''
41o9NC  <a href="http://qzgrfhmmoyrd.com/">qzgrfhmmoyrd</a>, [url=http://qwehxnjprxcd.com/]qwehxnjprxcd[/url], [link=http://ujtucdlfgtqx.com/]ujtucdlfgtqx[/link], http://pcxycuwhupfp.com/
2135天前 翻译
103#翻译
An unlimited-length text field.
一个不限长度的文字字段。
3410天前 翻译
104#翻译
TimeField
'''''''''
H5doOM  <a href="http://lxmsxnaxoere.com/">lxmsxnaxoere</a>, [url=http://xzpprtjavipk.com/]xzpprtjavipk[/url], [link=http://jmtvhzmjcubo.com/]jmtvhzmjcubo[/link], http://kpfpencdonzo.com/
2143天前 翻译
105#翻译
A time of day. It accepts the same autopopulation options as ``DateField`` and ``DateTimeField`` .
时分秒的时间显示。它接受的可指定参数与 ``DateField`` 和 ``DateTimeField`` 相同。
3320天前 翻译
106#翻译
URLField
''''''''
5AB8e2  <a href="http://eiuebxiufsnm.com/">eiuebxiufsnm</a>, [url=http://ggghqoccszkh.com/]ggghqoccszkh[/url], [link=http://rnjjffcnubzr.com/]rnjjffcnubzr[/link], http://bqgvycmugdch.com/
2144天前 翻译
107#翻译
A field for a URL. If the ``verify_exists`` option is ``True`` (the default), the URL given will be checked
for existence (i.e., the URL actually loads and doesnt give a 404 response).
IEHiqv  <a href="http://gkfflexmriao.com/">gkfflexmriao</a>, [url=http://opbpdvopzsit.com/]opbpdvopzsit[/url], [link=http://hmzcabuoacgq.com/]hmzcabuoacgq[/link], http://wxpttqqddctp.com/
2143天前 翻译
108#翻译
Like other character fields, ``URLField`` takes the ``maxlength`` argument. If you dont specify
``maxlength`` , a default of 200 is used.
8t232E  <a href="http://xnzhgpprvibj.com/">xnzhgpprvibj</a>, [url=http://fkflyvaxxgwk.com/]fkflyvaxxgwk[/url], [link=http://zutvzjgpxvwn.com/]zutvzjgpxvwn[/link], http://gwljwjcxqkec.com/
2144天前 翻译
109#翻译
USStateField
''''''''''''
USStateField
''''''''''''
3320天前 翻译
110#翻译
A two-letter U.S. state abbreviation.
GVXARd  <a href="http://owuknefobbbz.com/">owuknefobbbz</a>, [url=http://kcmhzdrceasb.com/]kcmhzdrceasb[/url], [link=http://oxbpzrarshgm.com/]oxbpzrarshgm[/link], http://alkecktlfvii.com/
2143天前 翻译
111#翻译
Note
RkdEGs  <a href="http://cmwqigygetau.com/">cmwqigygetau</a>, [url=http://geeuknibudtj.com/]geeuknibudtj[/url], [link=http://dspmscinyfuo.com/]dspmscinyfuo[/link], http://rnhzyiddejnv.com/
2144天前 翻译
112#翻译
If you need to represent other countries or states, look first in the ``django.contrib.localflavor`` package
to see if Django already includes fields for your locale.
YAnkiN  <a href="http://mnmmzfyvqaxy.com/">mnmmzfyvqaxy</a>, [url=http://ivghcreusdxo.com/]ivghcreusdxo[/url], [link=http://embvoyobbxkk.com/]embvoyobbxkk[/link], http://rwkacoiadnmd.com/
2144天前 翻译
113#翻译
XMLField
''''''''
XMLField
''''''''
3320天前 翻译
114#翻译
A ``TextField`` that checks that the value is valid XML that matches a given schema. It takes one required
argument, ``schema_path`` , which is the filesystem path to a RELAX NG (`http://www.relaxng.org/`_) schema
against which to validate the field.
它就是一个 ``TextField`` ,只不过要检查值是匹配指定schema的合法XML。它有一个必需参数: ``schema_path`` ,它是验证字段合法性所需的RELAX NG( `http://www.relaxng.org/`_ )schema的物理路径。
3320天前 翻译
115#翻译
Requires ``jing`` (`http://thaiopensource.com/relaxng/jing.html`_) to validate the XML.
Q3V3Dj  <a href="http://cjaqshzyqedq.com/">cjaqshzyqedq</a>, [url=http://xqedibprmwgt.com/]xqedibprmwgt[/url], [link=http://ozlcfmgznnsj.com/]ozlcfmgznnsj[/link], http://juawlnkqhvsl.com/
2135天前 翻译
116#翻译
Universal Field Options
```````````````````````
vZV8lL  <a href="http://kuqdtjlwucgk.com/">kuqdtjlwucgk</a>, [url=http://aszckocckybl.com/]aszckocckybl[/url], [link=http://ujqulrxqdspf.com/]ujqulrxqdspf[/link], http://qkaoyyqhcldl.com/
2136天前 Matty 翻译
117#翻译
The following arguments are available to all field types. All are optional.
urKAWY  <a href="http://ehpbvtkjmrff.com/">ehpbvtkjmrff</a>, [url=http://xmzodyutvivr.com/]xmzodyutvivr[/url], [link=http://jivviepnxydn.com/]jivviepnxydn[/link], http://fccyvtseoadl.com/
2134天前 翻译
118#翻译
null
''''
DVWs0f  <a href="http://jajhumxwmsme.com/">jajhumxwmsme</a>, [url=http://kegmwcstikyu.com/]kegmwcstikyu[/url], [link=http://umvekzvfeicm.com/]umvekzvfeicm[/link], http://uzbqvafaqgec.com/
2143天前 翻译
119#翻译
If ``True`` , Django will store empty values as ``NULL`` in the database. The default is ``False`` .
kJhk1f  <a href="http://irwnfhgtrzhx.com/">irwnfhgtrzhx</a>, [url=http://gmubkiaikssa.com/]gmubkiaikssa[/url], [link=http://bdnmczkjphet.com/]bdnmczkjphet[/link], http://ltbdqhnfigep.com/
2134天前 翻译
120#翻译
Note that empty string values will always get stored as empty strings, not as ``NULL`` . Only use
``null=True`` for nonstring fields such as integers, Booleans, and dates. For both types of fields, you will
also need to set ``blank=True`` if you wish to permit empty values in forms, as the ``null`` parameter only
affects database storage (see the following section, titled blank).
记住,空字符串值保存时总是以空字符串的形式存在,而不是 ``NULL`` 。一般只对非字符串字段使用 ``null=True`` ,比如整型、布尔型和日期型。对于这两种字段,如果你允许表单中的对应值为空的话,你还需要设定 ``blank=True`` ,因为 ``null`` 参数只影响数据库存储(参见下面题为blank的一节)。
3320天前 翻译
121#翻译
Avoid using ``null`` on string-based fields such as ``CharField`` and ``TextField`` unless you have an
excellent reason. If a string-based field has ``null=True`` , that means it has two possible values for no
data: ``NULL`` and the empty string. In most cases, its redundant to have two possible values for no data;
Djangos convention is to use the empty string, not ``NULL`` .
如果没有充分理由的话,应该尽量避免对诸如 ``CharField`` 和 ``TextField`` 这样字符串字段使用 ``null`` 参数。如果对字符串字段指定了 ``null=True`` 的话,这意味着空数据有两种可能的值: ``NULL`` 和空字符串。而大多数情况下,空数据没必要对应两种可能的值,所以Django中习惯使用空字符串,而不是 ``NULL`` 。
264天前 bfsffnpahz 翻译
122#翻译
blank
'''''
blank
'''''
3320天前 Dalton 翻译
123#翻译
If ``True`` , the field is allowed to be blank. The default is ``False`` .
如果是 ``True`` ,该字段允许留空,默认为 ``False`` 。
3320天前 翻译
124#翻译
Note that this is different from ``null`` . ``null`` is purely database related, whereas ``blank`` is
validation related. If a field has ``blank=True`` , validation on Djangos admin site will allow entry of an
empty value. If a field has ``blank=False`` , the field will be required.
AWdjBa  <a href="http://qbqovdrcypdt.com/">qbqovdrcypdt</a>, [url=http://zrsautjpgxvw.com/]zrsautjpgxvw[/url], [link=http://gesbnthytlcu.com/]gesbnthytlcu[/link], http://wxhjcldipgya.com/
2136天前 Anjii 翻译
125#翻译
choices
'''''''
choices
'''''''
3320天前 Lettie 翻译
126#翻译
An iterable (e.g., a list, tuple, or other iterable Python object) of two tuples to use as choices for this
field.
mabcco  <a href="http://mdejlwptfijx.com/">mdejlwptfijx</a>, [url=http://fftcnvxgcltx.com/]fftcnvxgcltx[/url], [link=http://irbcrqcoubji.com/]irbcrqcoubji[/link], http://fodzghmhwzbt.com/
2135天前 翻译
127#翻译
If this is given, Djangos admin interface will use a select box instead of the standard text field and will
limit choices to the choices given.
如果指定了这个选项,Django管理界面不会使用标准的文本框了,而是取而代之,使用列表选择框限定选择范围。
3318天前 翻译
128#翻译
A choices list looks like this:
BdkTFp  <a href="http://kyekkovdqfcz.com/">kyekkovdqfcz</a>, [url=http://yyhpuqoyjkwp.com/]yyhpuqoyjkwp[/url], [link=http://krbzkudndmsg.com/]krbzkudndmsg[/link], http://wgwzonqiqgxk.com/
2135天前 翻译
131#翻译
The first element in each tuple is the actual value to be stored. The second element is the human-readable
name for the option.
vLVl6n  <a href="http://bdvxixcjztnm.com/">bdvxixcjztnm</a>, [url=http://lvhvofbpjses.com/]lvhvofbpjses[/url], [link=http://ahcauecgvlvs.com/]ahcauecgvlvs[/link], http://qslkyowqzrhu.com/
2135天前 翻译
132#翻译
The choices list can be defined either as part of your model class:
选项列表既可以作为模型类的一部分来定义:
3318天前 翻译
135#翻译
or outside your model class altogether:
也可以定义到模型类的外面:
3318天前 翻译
138#翻译
For each model field that has ``choices`` set, Django will add a method to retrieve the human-readable name
for the fields current value. See Appendix C for more details.
MbYkfo  <a href="http://aqvlaqubdlme.com/">aqvlaqubdlme</a>, [url=http://pvnozqkdxtjt.com/]pvnozqkdxtjt[/url], [link=http://ztophwrdvqnt.com/]ztophwrdvqnt[/link], http://obfxbomnyfbu.com/
2135天前 翻译
139#翻译
db_column
'''''''''
ShTqnq  <a href="http://relghzyrpcfy.com/">relghzyrpcfy</a>, [url=http://cijcifbfahzp.com/]cijcifbfahzp[/url], [link=http://rakxjahtwhlc.com/]rakxjahtwhlc[/link], http://knyaprqcnmqw.com/
2143天前 翻译
140#翻译
The name of the database column to use for this field. If this isnt given, Django will use the fields name.
This is useful when youre defining a model around a database that already exists.
当前字段在数据库中对应的列的名字。如果没有指定的话,Django会使用这个字段的名字。当你要定义一个数据库中存在命名冲突的模型时,这个选项非常有用。
3318天前 翻译
141#翻译
If your database column name is an SQL reserved word, or if it contains characters that arent allowed in
Python variable names (notably the hyphen), thats OK. Django quotes column and table names behind the
scenes.
YJFBCZ  <a href="http://eetwxoqiwlnd.com/">eetwxoqiwlnd</a>, [url=http://zckafvbscirm.com/]zckafvbscirm[/url], [link=http://qudyypgrdtkj.com/]qudyypgrdtkj[/link], http://gbdvtpywtxxh.com/
2135天前 翻译
142#翻译
db_index
''''''''
db_index
''''''''
3320天前 翻译
143#翻译
If ``True`` , Django will create a database index on this column when creating the table (i.e., when running
``manage.py syncdb`` ). ta default -
如果为 ``True`` ,Django会在创建表格(比如运行 ``manage.py syncdb`` )时对这一列创建数据库索引。
3320天前 翻译
144#翻译
The default value for the field.
Sd053i  <a href="http://ivtiwhrceewi.com/">ivtiwhrceewi</a>, [url=http://rjjohdnqhnnf.com/]rjjohdnqhnnf[/url], [link=http://gyivjmkbhxpu.com/]gyivjmkbhxpu[/link], http://egxogdubdxub.com/
2135天前 Gerrie 翻译
145#翻译
editable
''''''''
editable
''''''''
3320天前 翻译
146#翻译
If ``False`` , the field will not be editable in the admin interface or via form processing. The default is
``True`` .
如果为 ``False`` ,这个字段在管理界面或表单里将不能编辑。默认为 ``True`` 。
3340天前 翻译
147#翻译
help_text
'''''''''
help_text
'''''''''
3320天前 翻译
148#翻译
Extra help text to be displayed under the field on the objects admin form. Its useful for documentation even
if your object doesnt have an admin form.
q1bnkH  <a href="http://mjbbpgegolxh.com/">mjbbpgegolxh</a>, [url=http://ngnnmhjfimcc.com/]ngnnmhjfimcc[/url], [link=http://oenapyddinuf.com/]oenapyddinuf[/link], http://fwvgjilylmxy.com/
2136天前 Terry 翻译
149#翻译
primary_key
'''''''''''
primary_key
'''''''''''
3320天前 翻译
150#翻译
If ``True`` , this field is the primary key for the model.
UYmpFc  <a href="http://wpxtieecdsyi.com/">wpxtieecdsyi</a>, [url=http://hpijzzynnlzv.com/]hpijzzynnlzv[/url], [link=http://sdrylpgmtksk.com/]sdrylpgmtksk[/link], http://cxhfiftbocqn.com/
2136天前 翻译
151#翻译
If you dont specify ``primary_key=True`` for any fields in your model, Django will automatically add this
field:
如果你没有对模型中的任何字段指定 ``primary_key=True`` 的话,Django会自动添加这个字段:
3320天前 翻译
154#翻译
Thus, you dont need to set ``primary_key=True`` on any of your fields unless you want to override the
default primary-key behavior.
2fpVmK  <a href="http://gdrgfkopjtxt.com/">gdrgfkopjtxt</a>, [url=http://nflrffsrzqbl.com/]nflrffsrzqbl[/url], [link=http://yvfnhmtpyfyn.com/]yvfnhmtpyfyn[/link], http://thsajuueyaln.com/
2143天前 翻译
155#翻译
``primary_key=True`` implies ``blank=False`` , ``null=False`` , and ``unique=True`` . Only one primary key
is allowed on an object.
eprg8T  <a href="http://edjyaqkxasnj.com/">edjyaqkxasnj</a>, [url=http://jxlmjecxflvz.com/]jxlmjecxflvz[/url], [link=http://ejpfjxhithgg.com/]ejpfjxhithgg[/link], http://rewizqlrumlq.com/
2143天前 翻译
156#翻译
radio_admin
'''''''''''
kNBICR  <a href="http://dnnaamiijpte.com/">dnnaamiijpte</a>, [url=http://yzlswyvejhar.com/]yzlswyvejhar[/url], [link=http://qibjuyoqdmvi.com/]qibjuyoqdmvi[/link], http://hpbnlgevstew.com/
2135天前 翻译
157#翻译
By default, Djangos admin uses a select-box interface (<select>) for fields that are ``ForeignKey`` or have
``choices`` set. If ``radio_admin`` is set to ``True`` , Django will use a radio-button interface instead.
默认地,对于 ``ForeignKey`` 或者拥有 ``choices`` 设置的字段,Django管理界面会使用列表选择框(<select>)。如果 ``radio_admin`` 设置为 ``True`` 的话,Django就会使用单选按钮界面。
3320天前 翻译
158#翻译
Dont use this for a field unless its a ``ForeignKey`` or has ``choices`` set.
2s8abv  <a href="http://gnejbijgqwxe.com/">gnejbijgqwxe</a>, [url=http://nlpgytzlpcef.com/]nlpgytzlpcef[/url], [link=http://hvieunrxdpzj.com/]hvieunrxdpzj[/link], http://icwbrrkamjog.com/
2136天前 翻译
159#翻译
unique
''''''
unique
''''''
3320天前 翻译
160#翻译
If ``True`` , the value for this field must be unique throughout the table.
kLWO0k  <a href="http://mbgpmvsnusic.com/">mbgpmvsnusic</a>, [url=http://fmpduyggzakg.com/]fmpduyggzakg[/url], [link=http://qsurimvuhmbb.com/]qsurimvuhmbb[/link], http://whbofjczmkyi.com/
2135天前 翻译
161#翻译
unique_for_date
'''''''''''''''
unique_for_date
'''''''''''''''
3320天前 翻译
162#翻译
Set to the name of a ``DateField`` or ``DateTimeField`` to require that this field be unique for the value
of the date field, for example:
CMFwXm  <a href="http://pprjingocyyq.com/">pprjingocyyq</a>, [url=http://wrbmqilasdpu.com/]wrbmqilasdpu[/url], [link=http://znwwhfdjownf.com/]znwwhfdjownf[/link], http://mtniiwgifvze.com/
2134天前 翻译
165#翻译
In the preceding code, Django wont allow the creation of two stories with the same slug published on the
same date. This differs from using a ``unique_together`` constraint in that only the date of the
``pub_date`` field is taken into account; the time doesnt matter.
OIaQu7  <a href="http://lsojtgyymjtn.com/">lsojtgyymjtn</a>, [url=http://chyyrrpvwzor.com/]chyyrrpvwzor[/url], [link=http://flajdibowdbg.com/]flajdibowdbg[/link], http://pznautgbqhno.com/
2143天前 翻译
166#翻译
unique_for_month
''''''''''''''''
x5pXZX  <a href="http://kongpbuctnfg.com/">kongpbuctnfg</a>, [url=http://qyxwseklnwdp.com/]qyxwseklnwdp[/url], [link=http://zwncxanyuotc.com/]zwncxanyuotc[/link], http://ansorrnjgzie.com/
2143天前 翻译
167#翻译
Like ``unique_for_date`` , but requires the field to be unique with respect to the month of the given field.
72oiML  <a href="http://qictlffamobc.com/">qictlffamobc</a>, [url=http://nqzhwzerkqna.com/]nqzhwzerkqna[/url], [link=http://qumhzlqwxgpe.com/]qumhzlqwxgpe[/link], http://qlubacioztwq.com/
2144天前 翻译
168#翻译
unique_for_year
'''''''''''''''
unique_for_year
'''''''''''''''
3320天前 翻译
169#翻译
Like ``unique_for_date`` and ``unique_for_month`` , but for an entire year.
UGmjjL  <a href="http://gbzqyjcunclt.com/">gbzqyjcunclt</a>, [url=http://oansmmuyjhud.com/]oansmmuyjhud[/url], [link=http://dqefedmfxavf.com/]dqefedmfxavf[/link], http://gqdqyveappxy.com/
2135天前 翻译
170#翻译
verbose_name
''''''''''''
omvb9v  <a href="http://xgvcjsftmnzb.com/">xgvcjsftmnzb</a>, [url=http://ujhkdbsibaaj.com/]ujhkdbsibaaj[/url], [link=http://ittwxfebdfwx.com/]ittwxfebdfwx[/link], http://snhtshvzmhpm.com/
2144天前 翻译
171#翻译
Each field type, except for ``ForeignKey`` , ``ManyToManyField`` , and ``OneToOneField`` , takes an optional
first positional argument a verbose name. If the verbose name isnt given, Django will automatically create
it using the fields attribute name, converting underscores to spaces.
QlAm5d  <a href="http://utuqfooxmnor.com/">utuqfooxmnor</a>, [url=http://ctxghvpssgay.com/]ctxghvpssgay[/url], [link=http://btkdivynnlml.com/]btkdivynnlml[/link], http://giezfzstyomq.com/
2143天前 翻译
172#翻译
In this example, the verbose name is ``"Person's first name"`` :
r4U68e  <a href="http://glbhlafguqxc.com/">glbhlafguqxc</a>, [url=http://byclclrrkkfv.com/]byclclrrkkfv[/url], [link=http://vxomddlohkne.com/]vxomddlohkne[/link], http://fdvynpvjommc.com/
2143天前 翻译
175#翻译
In this example, the verbose name is ``"first name"`` :
PJx0v8  <a href="http://klytqhfpgdul.com/">klytqhfpgdul</a>, [url=http://qnsisqwiwhbu.com/]qnsisqwiwhbu[/url], [link=http://memcsdcvlrkw.com/]memcsdcvlrkw[/link], http://rxifocwqwfte.com/
2134天前 翻译
178#翻译
``ForeignKey`` , ``ManyToManyField`` , and ``OneToOneField`` require the first argument to be a model class,
so use the ``verbose_name`` keyword argument:
r9jR22  <a href="http://nzwlzwzudoxr.com/">nzwlzwzudoxr</a>, [url=http://mlsnzfxnxhkk.com/]mlsnzfxnxhkk[/url], [link=http://dwwofklsbpbl.com/]dwwofklsbpbl[/link], http://gcygluvkvrli.com/
2136天前 翻译
181#翻译
The convention is not to capitalize the first letter of the ``verbose_name`` . Django will automatically
capitalize the first letter where it needs to.
oc5gwm  <a href="http://bhyqiqiiznvx.com/">bhyqiqiiznvx</a>, [url=http://dyxemachbqnk.com/]dyxemachbqnk[/url], [link=http://joklgfcofszz.com/]joklgfcofszz[/link], http://djfoateovxqq.com/
2135天前 翻译
182#翻译
Relationships
`````````````
1DAdAH  <a href="http://gjrcnimrtngy.com/">gjrcnimrtngy</a>, [url=http://gkhihcgulalb.com/]gkhihcgulalb[/url], [link=http://vbqasnwicofv.com/]vbqasnwicofv[/link], http://pwstoqpplafa.com/
2136天前 翻译
183#翻译
Clearly, the power of relational databases lies in relating tables to each other. Django offers ways to
define the three most common types of database relationships: many-to-one, many-to-many, and one-to-one.
很明显,关系数据库的强大在于表与表之间的相互关联关系,Django提供定义了三种最为通用的数库库关系类型:many-to-one(多对一关系),many-to-many(多对多关系)和one-to-one(一对一关系)
3318天前 翻译
184#翻译
However, the semantics of one-to-one relationships are being revisited as this book goes to print, so theyre
not covered in this section. Check the online documentation for the latest information.
GFDTf5  <a href="http://alxgoxpxkvra.com/">alxgoxpxkvra</a>, [url=http://fzuozegrndae.com/]fzuozegrndae[/url], [link=http://alzywfsafhue.com/]alzywfsafhue[/link], http://edzozitfdmge.com/
2143天前 翻译
185#翻译
Many-to-One Relationships
'''''''''''''''''''''''''
p7qd86  <a href="http://dfttrjisifii.com/">dfttrjisifii</a>, [url=http://gmpmdzjtupml.com/]gmpmdzjtupml[/url], [link=http://fsqtjhubctbj.com/]fsqtjhubctbj[/link], http://ptdhrsvmltzg.com/
2135天前 翻译
186#翻译
To define a many-to-one relationship, use ``ForeignKey`` . You use it just like any other ``Field`` type: by
including it as a class attribute of your model.
用 ``ForeignKey`` 来定义多对一的关系。用法和其他的 ``Field`` 是一样的,把它放到模型中类的属性定义中就行了。
3317天前 翻译
187#翻译
``ForeignKey`` requires a positional argument: the class to which the model is related.
6USNHR  <a href="http://zdsstknbkxde.com/">zdsstknbkxde</a>, [url=http://rehfvlfdwkzl.com/]rehfvlfdwkzl[/url], [link=http://eklnkfcfxqur.com/]eklnkfcfxqur[/link], http://wseyulkaqfui.com/
2143天前 翻译
188#翻译
For example, if a ``Car`` model has a ``Manufacturer`` that is, a ``Manufacturer`` makes multiple cars but
each ``Car`` only has one ``Manufacturer`` use the following definitions:
例如,一个 ``Car`` 模型中有个 ``Manufacturer`` ,就是说一个 ``Manufacturer`` 可以生产很多汽车,但是每个 ``Car`` 只能有一个 ``Manufacturer`` ,可以这样定义:
3317天前 翻译
191#翻译
To create a *recursive* relationship an object that has a many-to-one relationship with itself use
``models.ForeignKey('self')`` :
要建立一个 *递归* 的关系——就是一个对象和自身有多对一的关系——可以这样写: ``models.ForeignKey('self')`` :

3293天前 翻译
194#翻译
If you need to create a relationship on a model that has not yet been defined, you can use the name of the
model, rather than the model object itself:
KYlOG1  <a href="http://piqdgjicbgkv.com/">piqdgjicbgkv</a>, [url=http://yrrhslfhxdag.com/]yrrhslfhxdag[/url], [link=http://fmmmprdkyfhy.com/]fmmmprdkyfhy[/link], http://cpvkntllhrdc.com/
2136天前 翻译
197#翻译
Note, however, that you can only use strings to refer to models in the same ``models.py`` file you cannot
use a string to reference a model in a different application, or to reference a model that has been imported
from elsewhere.
Y0o71f  <a href="http://gnskifwjwawg.com/">gnskifwjwawg</a>, [url=http://buzuvavqvxfp.com/]buzuvavqvxfp[/url], [link=http://pbjhxfnaisna.com/]pbjhxfnaisna[/link], http://qappwpdifnfo.com/
2135天前 翻译
198#翻译
Behind the scenes, Django appends ``"_id"`` to the field name to create its database column name. In the
preceding example, the database table for the ``Car`` model will have a ``manufacturer_id`` column. (You can
change this explicitly by specifying ``db_column`` ; see the earlier db_column section.) However, your code
should never have to deal with the database column name, unless you write custom SQL. Youll always deal with
the field names of your model object.
n8cnhs  <a href="http://vqguaacqgeyn.com/">vqguaacqgeyn</a>, [url=http://dqnrbqbtfkfc.com/]dqnrbqbtfkfc[/url], [link=http://pxxmetmoenxx.com/]pxxmetmoenxx[/link], http://rqqwnvqglbqm.com/
2143天前 翻译
199#翻译
Its suggested, but not required, that the name of a ``ForeignKey`` field (``manufacturer`` in the example)
be the name of the model, in lowercase letters. You can, of course, call the field whatever you want, for
example:
qzIgmr  <a href="http://ysxgtfianzyc.com/">ysxgtfianzyc</a>, [url=http://smmzddcqbrjw.com/]smmzddcqbrjw[/url], [link=http://exmfxmlxhseg.com/]exmfxmlxhseg[/link], http://cpttbtjchsgq.com/
2135天前 翻译
202#翻译
``ForeignKey`` fields take a number of extra arguments for defining how the relationship should work (see
Table B-5). All are optional.
wqc8Za  <a href="http://eqkrooepsnth.com/">eqkrooepsnth</a>, [url=http://uvhrmznogane.com/]uvhrmznogane[/url], [link=http://kpzhldwgxolu.com/]kpzhldwgxolu[/link], http://hqniauicvgfe.com/
2143天前 翻译
203#翻译
.. table:: Table B-5. ForeignKey Options

    +-----------------------+----------------------------------------------------------------------------------+
    |Argument               |Description                                                                       |
    +=======================+==================================================================================+
    |``edit_inline``        |If not ``False`` , this related object is edited inline on the related objects    |
    |                       |page. This means that the object will not have its own admin interface. Use either|
    |                       |``models.TABULAR`` or ``models.STACKED`` , which, respectively, designate whether |
    |                       |the inline-editable objects are displayed as a table or as a stack of fieldsets.  |
    +-----------------------+----------------------------------------------------------------------------------+
    |``limit_choices_to``   |A dictionary of lookup arguments and values (see Appendix C) that limit the       |
    |                       |available admin choices for this object. Use this with functions from the Python  |
    |                       |``datetime`` module to limit choices of objects by date. For example, the         |
    |                       |following:                                                                        |
    |                       |                                                                                  |
    |                       |::                                                                                |
    |                       |                                                                                  |
    |                       |                                                                                  |
    |                       |    limit_choices_to = {'pub_date__lte': datetime.now}                            |
    |                       |                                                                                  |
    |                       |..                                                                                |
    |                       |                                                                                  |
    |                       |                                                                                  |
    |                       |                                                                                  |
    |                       |only allows the choice of related objects with a ``pub_date`` before the current  |
    |                       |date/time to be chosen.                                                           |
    |                       |                                                                                  |
    |                       |Instead of a dictionary, this can be a ``Q`` object (see Appendix C) for more     |
    |                       |complex queries.                                                                  |
    |                       |                                                                                  |
    |                       |This is not compatible with ``edit_inline`` .                                     |
    +-----------------------+----------------------------------------------------------------------------------+
    |``max_num_in_admin``   |For inline-edited objects, this is the maximum number of related objects to       |
    |                       |display in the admin interface. Thus, if a pizza could have only up to ten        |
    |                       |toppings, ``max_num_in_admin=10`` would ensure that a user never enters more than |
    |                       |ten toppings.                                                                     |
    |                       |                                                                                  |
    |                       |Note that this doesnt ensure more than ten related toppings ever get created. It  |
    |                       |simply controls the admin interface; it doesnt enforce things at the Python API   |
    |                       |level or database level.                                                          |
    +-----------------------+----------------------------------------------------------------------------------+
    |``min_num_in_admin``   |The minimum number of related objects displayed in the admin interface. Normally, |
    |                       |at the creation stage, ``num_in_admin`` inline objects are shown, and at the edit |
    |                       |stage, ``num_extra_on_change`` blank objects are shown in addition to all         |
    |                       |pre-existing related objects. However, no fewer than ``min_num_in_admin`` related |
    |                       |objects will ever be displayed.                                                   |
    +-----------------------+----------------------------------------------------------------------------------+
    |``num_extra_on_change``|The number of extra blank related-object fields to show at the change stage.      |
    +-----------------------+----------------------------------------------------------------------------------+
    |``num_in_admin``       |The default number of inline objects to display on the object page at the add     |
    |                       |stage.                                                                            |
    +-----------------------+----------------------------------------------------------------------------------+
    |``raw_id_admin``       |Only display a field for the integer to be entered instead of a drop-down menu.   |
    |                       |This is useful when related to an object type that will have too many rows to make|
    |                       |a select box practical.                                                           |
    |                       |                                                                                  |
    |                       |This is not used with ``edit_inline`` .                                           |
    +-----------------------+----------------------------------------------------------------------------------+
    |``related_name``       |The name to use for the relation from the related object back to this one. See    |
    |                       |Appendix C for more information.                                                  |
    +-----------------------+----------------------------------------------------------------------------------+
    |``to_field``           |The field on the related object that the relation is to. By default, Django uses  |
    |                       |the primary key of the related object.                                            |
    +-----------------------+----------------------------------------------------------------------------------+
    
6FzIoP  <a href="http://cfbillraxrtd.com/">cfbillraxrtd</a>, [url=http://tykqzqebrnte.com/]tykqzqebrnte[/url], [link=http://usbunnmcfgzg.com/]usbunnmcfgzg[/link], http://jifonaxttcji.com/
2135天前 翻译
206#翻译
Many-to-Many Relationships
''''''''''''''''''''''''''
多对多关系
''''''''''''''''''''''''''
3347天前 翻译
207#翻译
To define a many-to-many relationship, use ``ManyToManyField`` . Like ``ForeignKey`` , ``ManyToManyField``
requires a positional argument: the class to which the model is related.
owYLDb  <a href="http://gjuxwxafixga.com/">gjuxwxafixga</a>, [url=http://ckdqqcpwpkjj.com/]ckdqqcpwpkjj[/url], [link=http://gefaqukepstz.com/]gefaqukepstz[/link], http://doxmhqbegwia.com/
2135天前 翻译
208#翻译
For example, if a ``Pizza`` has multiple ``Topping`` objects that is, a ``Topping`` can be on multiple
pizzas and each ``Pizza`` has multiple toppings heres how youd represent that:
HQRVOo  <a href="http://xiknfopginyx.com/">xiknfopginyx</a>, [url=http://vecncneymqza.com/]vecncneymqza[/url], [link=http://gcqfedoygdnf.com/]gcqfedoygdnf[/link], http://yezjqheznesf.com/
2135天前 翻译
211#翻译
As with ``ForeignKey`` , a relationship to self can be defined by using the string ``'self'`` instead of the
model name, and you can refer to as-yet undefined models by using a string containing the model name.
However, you can only use strings to refer to models in the same ``models.py`` file you cannot use a string
to reference a model in a different application, or to reference a model that has been imported from
elsewhere.
wzCByt  <a href="http://epvmwilwfiuu.com/">epvmwilwfiuu</a>, [url=http://vgbixmpfskgj.com/]vgbixmpfskgj[/url], [link=http://ndylockyqkgc.com/]ndylockyqkgc[/link], http://govmwelxrfiq.com/
2135天前 翻译
212#翻译
Its suggested, but not required, that the name of a ``ManyToManyField`` (``toppings`` in the example) be a
plural term describing the set of related model objects.
nrPcTI  <a href="http://gwdsikgpfkfx.com/">gwdsikgpfkfx</a>, [url=http://fqcopieroseg.com/]fqcopieroseg[/url], [link=http://xrebnpxkafip.com/]xrebnpxkafip[/link], http://kpaprejfxufg.com/
2136天前 翻译
213#翻译
Behind the scenes, Django creates an intermediary join table to represent the many-to-many relationship.
TJAnZY  <a href="http://xvacpzbfbkxi.com/">xvacpzbfbkxi</a>, [url=http://lfoiapvqzrti.com/]lfoiapvqzrti[/url], [link=http://zgmqwkztagrt.com/]zgmqwkztagrt[/link], http://osktrrazjebz.com/
2136天前 翻译
214#翻译
It doesnt matter which model gets the ``ManyToManyField`` , but you need it in only one of the models not in
both.
1Bl7oT  <a href="http://epphitdetoos.com/">epphitdetoos</a>, [url=http://hdebeujbyofp.com/]hdebeujbyofp[/url], [link=http://rjynxktskihv.com/]rjynxktskihv[/link], http://eluozbxntcqn.com/
2135天前 翻译
215#翻译
If youre using the admin interface, ``ManyToManyField`` instances should go in the object thats going to be
edited in the admin interface. In the preceding example, ``toppings`` is in ``Pizza`` (rather than
``Topping`` having a ``pizzas`` ``ManyToManyField`` ) because its more natural to think about a ``Pizza``
having toppings than a topping being on multiple pizzas. The way its set up in the example, the ``Pizza``
admin form would let users select the toppings.
如果你是用管理界面的话, ``ManyToManyField`` 实例应该放到要在管理界面编辑的对象里。在前面的例子里,是 ``toppings`` 位于 ``Pizza`` 中的(而不是 ``Topping`` 中有一个名为 ``pizzas`` 的 ``ManyToManyField`` ),因为这样比一种配料放到多个披萨中更符合人们的思维习惯。在这个例子中,用户可以在 ``Pizza`` 的管理界面中选择配料。
264天前 uesblnbswyx 翻译
216#翻译
``ManyToManyField`` objects take a number of extra arguments for defining how the relationship should work
(see Table B-6). All are optional.
JBFlaU  <a href="http://vsfpmxwdjegs.com/">vsfpmxwdjegs</a>, [url=http://cyvjmleohtnu.com/]cyvjmleohtnu[/url], [link=http://rgfnqlmnmkgc.com/]rgfnqlmnmkgc[/link], http://onwrmzlknmnb.com/
2143天前 翻译
217#翻译
.. table:: Table B-6. ManyToManyField Options

    +--------------------+-------------------------------------------------------------------------------------+
    |Argument            |Description                                                                          |
    +====================+=====================================================================================+
    |``related_name``    |The name to use for the relation from the related object back to this one. See       |
    |                    |Appendix C for more information.                                                     |
    +--------------------+-------------------------------------------------------------------------------------+
    |``filter_interface``|Use a nifty, unobtrusive JavaScript filter interface instead of the                  |
    |                    |usability-challenged ``<select multiple>`` in the admin form for this object. The    |
    |                    |value should be ``models.HORIZONTAL`` or ``models.VERTICAL`` (i.e., should the       |
    |                    |interface be stacked horizontally or vertically).                                    |
    +--------------------+-------------------------------------------------------------------------------------+
    |``limit_choices_to``|See the description under ``ForeignKey`` .                                           |
    +--------------------+-------------------------------------------------------------------------------------+
    |``symmetrical``     |Only used in the definition of ``ManyToManyField`` on self. Consider the following   |
    |                    |model:                                                                               |
    |                    |                                                                                     |
    |                    |::                                                                                   |
    |                    |                                                                                     |
    |                    |                                                                                     |
    |                    |    class Person(models.Model):                                                      |
    |                    |        friends = models.ManyToManyField("self")                                     |
    |                    |                                                                                     |
    |                    |..                                                                                   |
    |                    |                                                                                     |
    |                    |                                                                                     |
    |                    |                                                                                     |
    |                    |When Django processes this model, it identifies that it has a ``ManyToManyField`` on |
    |                    |itself, and as a result, it doesnt add a ``person_set`` attribute to the ``Person``  |
    |                    |class. Instead, the ``ManyToManyField`` is assumed to be symmetrical that is, if I am|
    |                    |your friend, then you are my friend.                                                 |
    |                    |                                                                                     |
    |                    |If you do not want symmetry in ``ManyToMany`` relationships with ``self`` , set      |
    |                    |``symmetrical`` to ``False`` . This will force Django to add the descriptor for the  |
    |                    |reverse relationship, allowing ``ManyToMany`` relationships to be nonsymmetrical.    |
    +--------------------+-------------------------------------------------------------------------------------+
    |``db_table``        |The name of the table to create for storing the many-to-many data. If this is not    |
    |                    |provided, Django will assume a default name based upon the names of the two tables   |
    |                    |being joined.                                                                        |
    +--------------------+-------------------------------------------------------------------------------------+
    
.. table:: 表B-6. ManyToManyField选项

    +--------------------+-------------------------------------------------------------------------------------+
    |参数                |描述                                                                                 |
    +====================+=====================================================================================+
    |``related_name``    |关联对象反向引用描述符。更多信息参见附录C。                                          |
    +--------------------+-------------------------------------------------------------------------------------+
    |``filter_interface``|在这个对象的管理界面里面,使用简单易用的JavaScript过滤界面,而不是使用可用性较差的   |
    |                    |``<select multiple>`` 。它的值应该是 ``models.HORIZONTAL`` 或者 ``models.VERTICAL``  |
    |                    |(就是说界面应该横放还是竖放)。                                                     |
    +--------------------+-------------------------------------------------------------------------------------+
    |``limit_choices_to``|参见 ``ForeignKey`` 中对本项的描述。                                                 |
    +--------------------+-------------------------------------------------------------------------------------+
    |``symmetrical``     |仅用于模型定义指向自身的 ``ManyToManyField`` 的情况。看下面这个模型:                |
    |                    |                                                                                     |
    |                    |::                                                                                   |
    |                    |                                                                                     |
    |                    |                                                                                     |
    |                    |    class Person(models.Model):                                                      |
    |                    |        friends = models.ManyToManyField("self")                                     |
    |                    |                                                                                     |
    |                    |..                                                                                   |
    |                    |                                                                                     |
    |                    |                                                                                     |
    |                    |                                                                                     |
    |                    |当Django处理这个模型时,会发现它有一个指向自身的 ``ManyToManyField`` ,它因此就不会在|
    |                    |``Person`` 类中添加 ``person_set`` 属性。而对于 ``ManyToManyField`` ,我们会假定这种 |
    |                    |关系是对称的,就是说,如果我是你的朋友,你也是我的朋友。                             |
    |                    |                                                                                     |
    |                    |在对 ``self`` 的 ``ManyToMany`` 关系中,如果你不需要这种对称性,你可以把             |
    |                    |``symmetrical`` 的值设为 ``False`` 。这样就会强制Django给关系的另外一方添加描述符,  |
    |                    |从而使这种关系不是对称的。                                                           |
    +--------------------+-------------------------------------------------------------------------------------+
    |``db_table``        |用来保存多对多数据的表的名字。如果没有提供本项的话,Django会把两个表的名字连接起来当 |
    |                    |做多对多数据表的默认名字。                                                           |
    +--------------------+-------------------------------------------------------------------------------------+
    
260天前 bniuse 翻译
220#翻译
Model Metadata Options
``````````````````````
13gIw0  <a href="http://sscmnzloyfgv.com/">sscmnzloyfgv</a>, [url=http://spxlbmyezvpk.com/]spxlbmyezvpk[/url], [link=http://mmiqhlemjbwj.com/]mmiqhlemjbwj[/link], http://ggidkspvdbtt.com/
2134天前 翻译
221#翻译
Model-specific metadata lives in a ``class Meta`` defined in the body of your model class:
q4wCqF  <a href="http://ujvctiyxerdr.com/">ujvctiyxerdr</a>, [url=http://zfztncixykpp.com/]zfztncixykpp[/url], [link=http://tezeewkenxgk.com/]tezeewkenxgk[/link], http://bdbhykyxfxcz.com/
2136天前 翻译
224#翻译
Model metadata is anything thats not a field, such as ordering options and so forth.
5X0yKB  <a href="http://xlfxtvanzsvs.com/">xlfxtvanzsvs</a>, [url=http://vdidkvkivsny.com/]vdidkvkivsny[/url], [link=http://kstrtjdqpkte.com/]kstrtjdqpkte[/link], http://fnvjdqnmvggr.com/
2143天前 翻译
225#翻译
The sections that follow present a list of all possible ``Meta`` options. No options are required. Adding
``class Meta`` to a model is completely optional.
wzu7mw  <a href="http://fdybefwcqpbm.com/">fdybefwcqpbm</a>, [url=http://tbiwaaqsmmzv.com/]tbiwaaqsmmzv[/url], [link=http://nthrgpcwgtgx.com/]nthrgpcwgtgx[/link], http://suuwhzxvuexr.com/
2144天前 翻译
226#翻译
db_table
''''''''
db_table
''''''''
3320天前 翻译
227#翻译
The name of the database table to use for the model.
ptFBId  <a href="http://dizludlvdvam.com/">dizludlvdvam</a>, [url=http://feigeddqkshf.com/]feigeddqkshf[/url], [link=http://pkmymjkwgrwj.com/]pkmymjkwgrwj[/link], http://hkcyuapirtpx.com/
2143天前 翻译
228#翻译
To save you time, Django automatically derives the name of the database table from the name of your model
class and the application that contains it. A models database table name is constructed by joining the
models app label the name you used in ``manage.py startapp`` to the models class name, with an underscore
between them.
为了节省时间,Django通过你定义的模型的类名和所在的应用程序的名称自动得到数据库的表名,它是由模型的应用程序名称——就是你执行 ``manage.py startapp`` 命令所指定的应用程序的名称——和模型的类名组成的,它们之间通过下划线进行连接。
370天前 翻译
229#翻译
For example, if you have an application ``books`` (as created by ``manage.py startapp books`` ), a model
defined as ``class Book`` will have a database table named ``books`` .
1msLMM  <a href="http://xvmlagtfwijm.com/">xvmlagtfwijm</a>, [url=http://lwycwnxymkxa.com/]lwycwnxymkxa[/url], [link=http://lnhwcjibczbr.com/]lnhwcjibczbr[/link], http://ujmkislozrxn.com/
2144天前 翻译
230#翻译
To override the database table name, use the ``db_table`` parameter in ``class Meta`` :
通过复写 ``class Meta`` 中的 ``db_table`` 参数可以改变模型映射的数据库表名:
3318天前 翻译
233#翻译
If this isnt given, Django will use ``app_label + '_' + model_class_name`` . See the section Table Names for
more information.
QiUWjL  <a href="http://etehwczlfhby.com/">etehwczlfhby</a>, [url=http://cvitpkdqztrq.com/]cvitpkdqztrq[/url], [link=http://grqclyedadhj.com/]grqclyedadhj[/link], http://bnmlrvdrphqv.com/
2143天前 翻译
234#翻译
If your database table name is an SQL reserved word, or it contains characters that arent allowed in Python
variable names (notably the hyphen), thats OK. Django quotes column and table names behind the scenes.
wlJKIi  <a href="http://kvejzmfwkvla.com/">kvejzmfwkvla</a>, [url=http://kygvvswsmsvf.com/]kygvvswsmsvf[/url], [link=http://napevipgxgfj.com/]napevipgxgfj[/link], http://ckrltgibasoh.com/
2135天前 翻译
235#翻译
get_latest_by
'''''''''''''
XZXXji  <a href="http://xidiruujzzbf.com/">xidiruujzzbf</a>, [url=http://exmdfzejuiox.com/]exmdfzejuiox[/url], [link=http://fsopppjzbvqb.com/]fsopppjzbvqb[/link], http://grvpsajkzyml.com/
2135天前 翻译
236#翻译
The name of a ``DateField`` or ``DateTimeField`` in the model. This specifies the default field to use in
your model ``Manager`` s ``latest()`` method.
94R17m  <a href="http://efgunidzecqf.com/">efgunidzecqf</a>, [url=http://bbonjfhkzdzi.com/]bbonjfhkzdzi[/url], [link=http://tiyeghfapzzd.com/]tiyeghfapzzd[/link], http://jahwpsnktnfu.com/
2136天前 翻译
237#翻译
Heres an example:
YFcyGV  <a href="http://ffqwqyceztmc.com/">ffqwqyceztmc</a>, [url=http://fsprcijzhury.com/]fsprcijzhury[/url], [link=http://dbyqvusgzten.com/]dbyqvusgzten[/link], http://ddcbhjbqhcqs.com/
2134天前 翻译
240#翻译
See Appendix C for more information on the ``latest()`` method.
关于 ``latest()`` 方法的更多信息可参考附录C。
3318天前 翻译
241#翻译
order_with_respect_to
'''''''''''''''''''''
YdjUFK  <a href="http://telxdshyupdv.com/">telxdshyupdv</a>, [url=http://bpxxekmaggoo.com/]bpxxekmaggoo[/url], [link=http://rvqzecfwkwap.com/]rvqzecfwkwap[/link], http://bhzleleexump.com/
2135天前 翻译
242#翻译
Marks this object as orderable with respect to the given field. This is almost always used with related
objects to allow them to be ordered with respect to a parent object. For example, if an ``Answer`` relates
to a ``Question`` object, and a question has more than one answer, and the order of answers matters, youd do
this:
标识这个对象可以根据指定字段排序,这个主要用于相互关联的对象,让他们可以按照和父对象相关的方式排序。例如,如果 ``Answer`` 和 ``Question`` 对象相关,同一个问题可能对应多个答案,如果答案顺序很重要的话,你应该这样做:
264天前 brhjsyygryt 翻译
245#翻译
ordering
''''''''
mXiwpB  <a href="http://mjpckssfnxrr.com/">mjpckssfnxrr</a>, [url=http://bvekvvnyuopy.com/]bvekvvnyuopy[/url], [link=http://piihretjzwfh.com/]piihretjzwfh[/link], http://ffomntjqeulv.com/
2143天前 翻译
246#翻译
The default ordering for the object, for use when obtaining lists of objects:
z7cZ0i  <a href="http://dxwxvlwtzfeh.com/">dxwxvlwtzfeh</a>, [url=http://szrgxumxqqxo.com/]szrgxumxqqxo[/url], [link=http://ojbwemtuntuw.com/]ojbwemtuntuw[/link], http://yyzjyuzxtlbh.com/
2143天前 翻译
249#翻译
This is a tuple or list of strings. Each string is a field name with an optional ``-`` prefix, which
indicates descending order. Fields without a leading ``-`` will be ordered ascending. Use the string ``"?"``
to order randomly.
3jTtLp  <a href="http://knckhvgxsxlb.com/">knckhvgxsxlb</a>, [url=http://wrrfziuwnpze.com/]wrrfziuwnpze[/url], [link=http://ebelfvrsmzju.com/]ebelfvrsmzju[/link], http://xsgalxaywynp.com/
2135天前 翻译
250#翻译
For example, to order by a ``title`` field in ascending order (i.e., A-Z), use this:
YmN84X  <a href="http://vilaoiqdzqaj.com/">vilaoiqdzqaj</a>, [url=http://mblkjhogydyx.com/]mblkjhogydyx[/url], [link=http://nscaeuqdafqz.com/]nscaeuqdafqz[/link], http://zzlzclxbnbro.com/
2144天前 翻译
253#翻译
To order by ``title`` in descending order (i.e., Z-A), use this:
FjbSep  <a href="http://mtwjksqxborv.com/">mtwjksqxborv</a>, [url=http://cbcqvaozxpix.com/]cbcqvaozxpix[/url], [link=http://ahqwhfexyggi.com/]ahqwhfexyggi[/link], http://djkfyjdvthws.com/
2144天前 翻译
256#翻译
To order by ``title`` in descending order, and then by ``title`` in ascending order, use this:
EzKyzC  <a href="http://bpuhqrgyxlfu.com/">bpuhqrgyxlfu</a>, [url=http://ioveitjshjpd.com/]ioveitjshjpd[/url], [link=http://facgutbfceyl.com/]facgutbfceyl[/link], http://agqrtbddgzkv.com/
2135天前 翻译
259#翻译
Note that, regardless of how many fields are in ``ordering`` , the admin site uses only the first field.
注意,无论 ``ordering`` 中有多少字段,admin界面只使用第一个字段。
3320天前 翻译
260#翻译
permissions
'''''''''''
permissions
'''''''''''
3320天前 翻译
261#翻译
Extra permissions to enter into the permissions table when creating this object. Add, delete, and change
permissions are automatically created for each object that has ``admin`` set. This example specifies an
extra permission, ``can_deliver_pizzas`` :
DWUPFr  <a href="http://zjywwczpkqtk.com/">zjywwczpkqtk</a>, [url=http://qjwywxmxkwqh.com/]qjwywxmxkwqh[/url], [link=http://iuydzmuwhzvd.com/]iuydzmuwhzvd[/link], http://hwwpxxexmyuo.com/
2135天前 翻译
264#翻译
This is a list or tuple of two tuples in the format ``(permission_code, human_readable_permission_name)`` .
h64M8C  <a href="http://xldflnwfvqut.com/">xldflnwfvqut</a>, [url=http://niqpgqvgdtqy.com/]niqpgqvgdtqy[/url], [link=http://pamhftntfchr.com/]pamhftntfchr[/link], http://aeasfbmucchv.com/
2135天前 翻译
265#翻译
See Chapter 12 for more on permissions.
有关权限的更多信息参见第12章。
3318天前 翻译
266#翻译
unique_together
'''''''''''''''
a0Hrkd  <a href="http://iaqmkuwxxumb.com/">iaqmkuwxxumb</a>, [url=http://ofegngpwsuhh.com/]ofegngpwsuhh[/url], [link=http://zitdmamqhbym.com/]zitdmamqhbym[/link], http://qsxshorrzwgm.com/
2136天前 翻译
267#翻译
Sets of field names that, taken together, must be unique:
2MjoJT  <a href="http://uzlhhioqmbtg.com/">uzlhhioqmbtg</a>, [url=http://zunpvwpjrkrj.com/]zunpvwpjrkrj[/url], [link=http://wxprpndxwkgy.com/]wxprpndxwkgy[/link], http://sgkjuprfrixh.com/
2136天前 翻译
270#翻译
This is a list of lists of fields that must be unique when considered together. Its used in the Django admin
interface and is enforced at the database level (i.e., the appropriate ``UNIQUE`` statements are included in
the ``CREATE TABLE`` statement).
这是一个由一些字段列表组成的列表,每个列表里的字段的组合值必须是唯一的。它用于Django管理界面,而且在数据库层是强制要求的(就是说在 ``CREATE TABLE`` 语句中会包含一些 ``UNIQUE`` 语句)。
3318天前 翻译
271#翻译
verbose_name
''''''''''''
t77tUp  <a href="http://whojrdjihtrm.com/">whojrdjihtrm</a>, [url=http://sinqinohypwo.com/]sinqinohypwo[/url], [link=http://blqbubcqbwds.com/]blqbubcqbwds[/link], http://ccyseljmmgbu.com/
2136天前 翻译
272#翻译
A human-readable name for the object, singular:
4BSZAt  <a href="http://djaflphpxbjg.com/">djaflphpxbjg</a>, [url=http://gxlddwzdpjvk.com/]gxlddwzdpjvk[/url], [link=http://jhnvrspkybsf.com/]jhnvrspkybsf[/link], http://yyicbgzatnrj.com/
2135天前 翻译
275#翻译
If this isnt given, Django will use a adapted version of the class name in which ``CamelCase`` becomes
``camel case`` .
如果没有给出此选项,那么Django将会根据类名来得到一个名称,例如 ``CamelCase`` 就会变成 ``camel case`` 。
3300天前 翻译
276#翻译
verbose_name_plural
'''''''''''''''''''
UfWFBw  <a href="http://ilyxotrloovo.com/">ilyxotrloovo</a>, [url=http://aogwttbwmxny.com/]aogwttbwmxny[/url], [link=http://dwfhccfhumql.com/]dwfhccfhumql[/link], http://opujnlbygptk.com/
2135天前 翻译
277#翻译
The plural name for the object:
对象复数形式的名字:
3300天前 翻译
280#翻译
If this isnt given, Django will add an s to the ``verbose_name`` .
EGZW8N  <a href="http://byndqdkrbdkn.com/">byndqdkrbdkn</a>, [url=http://msqfrvidrwzr.com/]msqfrvidrwzr[/url], [link=http://qbhtpepqmiap.com/]qbhtpepqmiap[/link], http://nhsqvmrjvnds.com/
2144天前 翻译
281#翻译
Managers
````````
60LJei  <a href="http://plhnnjddmlki.com/">plhnnjddmlki</a>, [url=http://ltysrpbqxgeu.com/]ltysrpbqxgeu[/url], [link=http://vevgdraxrmwx.com/]vevgdraxrmwx[/link], http://xhkqrgklbupr.com/
2143天前 翻译
282#翻译
A ``Manager`` is the interface through which database query operations are provided to Django models. At
least one ``Manager`` exists for every model in a Django application.
T9drol  <a href="http://eangvtfevkiy.com/">eangvtfevkiy</a>, [url=http://wbvvcgnfnmrk.com/]wbvvcgnfnmrk[/url], [link=http://ciiixxyqwkwa.com/]ciiixxyqwkwa[/link], http://uhbbtqvxdqju.com/
2143天前 翻译
283#翻译
The way ``Manager`` classes work is documented in Appendix C. This section specifically touches on model
options that customize ``Manager`` behavior.
LuujQ6  <a href="http://biwlfmrfzzas.com/">biwlfmrfzzas</a>, [url=http://jrtwnkfewjwb.com/]jrtwnkfewjwb[/url], [link=http://rfhmumbemtsq.com/]rfhmumbemtsq[/link], http://wynbkcwyxxci.com/
2144天前 翻译
284#翻译
Manager Names
'''''''''''''
管理器名称
''''''''''
3320天前 翻译
285#翻译
By default, Django adds a ``Manager`` with the name ``objects`` to every Django model class. However, if you
want to use ``objects`` as a field name, or if you want to use a name other than ``objects`` for the
``Manager`` , you can rename it on a per-model basis. To rename the ``Manager`` for a given class, define a
class attribute of type ``models.Manager()`` on that model, for example:
Django默认会给每个模型添加一个叫做 ``objects`` 的 ``Manager`` 。如果你想把一个字段命名为 ``objects`` 的话,或者你不想把 ``Manager`` 命名为 ``objects`` ,你可以在每个模型里做修改。在模型里面定一个 ``models.Manager()`` 类型的类属性,就可以修改这个类的 ``Manager`` 的名字了,例如:
243天前 unkfcvtt 翻译
288#翻译
Using this example model, ``Person.objects`` will generate an ``AttributeError`` exception (since ``Person``
doesnt have a ``objects`` attribute), but ``Person.people.all()`` will provide a list of all ``Person``
objects.
w5LJjz  <a href="http://nmctodvzrypj.com/">nmctodvzrypj</a>, [url=http://iuycwggtzahu.com/]iuycwggtzahu[/url], [link=http://uubizxqapwtf.com/]uubizxqapwtf[/link], http://lwkloizsvbvi.com/
2134天前 翻译
289#翻译
Custom Managers
'''''''''''''''
w4Rr3l  <a href="http://hxkvfclzprji.com/">hxkvfclzprji</a>, [url=http://cgcmictbdtgc.com/]cgcmictbdtgc[/url], [link=http://kuzwmmchaldp.com/]kuzwmmchaldp[/link], http://ibyfqovdapgz.com/
2143天前 翻译
290#翻译
You can use a custom ``Manager`` in a particular model by extending the base ``Manager`` class and
instantiating your custom ``Manager`` in your model.
i2kzYA  <a href="http://tkfukseshcib.com/">tkfukseshcib</a>, [url=http://pasqfavcpqra.com/]pasqfavcpqra[/url], [link=http://itzzkfieoikx.com/]itzzkfieoikx[/link], http://xnmbaowcdxtt.com/
2136天前 翻译
291#翻译
There are two reasons you might want to customize a ``Manager`` : to add extra ``Manager`` methods, and/or
to modify the initial ``QuerySet`` the ``Manager`` returns.
OTOTwd  <a href="http://dgwtcanxrozi.com/">dgwtcanxrozi</a>, [url=http://izbmuqidjnxf.com/]izbmuqidjnxf[/url], [link=http://ydyfxtfwwvxm.com/]ydyfxtfwwvxm[/link], http://cycivjvljiza.com/
2134天前 翻译
292#翻译
Adding Extra Manager Methods
............................
2354Fc  <a href="http://qdtxytieiily.com/">qdtxytieiily</a>, [url=http://kbbwwzyyjjlv.com/]kbbwwzyyjjlv[/url], [link=http://pqqulizfiimt.com/]pqqulizfiimt[/link], http://llzardlanyet.com/
2135天前 翻译
293#翻译
Adding extra ``Manager`` methods is the preferred way to add table-level functionality to your models. (For
row-level functionality that is, functions that act on a single instance of a model object use model methods
(see below), not custom ``Manager`` methods.)
增加附加的 ``Manager`` 方法是在模型中增加数据表级别的功能的首选方法。(对于行级别的功能——就是作用于模型的单个实例上的功能——要使用模型方法(下面有介绍),而不是定制的 ``Manager`` 方法。)
3316天前 翻译
294#翻译
A custom ``Manager`` method can return anything you want. It doesnt have to return a ``QuerySet`` .
wbyIGZ  <a href="http://bdvzelvswpyl.com/">bdvzelvswpyl</a>, [url=http://tleuilchmsax.com/]tleuilchmsax[/url], [link=http://fhaaymygckju.com/]fhaaymygckju[/link], http://tyrjipbbjkrg.com/
2144天前 翻译
295#翻译
For example, this custom ``Manager`` offers a method ``with_counts()`` , which returns a list of all
``OpinionPoll`` objects, each with an extra ``num_responses`` attribute that is the result of an aggregate
query:
jpNASZ  <a href="http://wlfemapppidk.com/">wlfemapppidk</a>, [url=http://hskgcqywvfhy.com/]hskgcqywvfhy[/url], [link=http://amumlqsppwdt.com/]amumlqsppwdt[/link], http://pyxrpwrvrpkx.com/
2143天前 翻译
298#翻译
With this example, youd use ``OpinionPoll.objects.with_counts()`` to return that list of ``OpinionPoll``
objects with ``num_responses`` attributes.
在这个例子中,你通过调用 ``OpinionPoll.objects.with_counts()`` 来返回的所有的 ``OpinionPoll`` 对象都拥有一个 ``num_responses`` 属性。
3312天前 翻译
299#翻译
Another thing to note about this example is that ``Manager`` methods can access ``self.model`` to get the
model class to which theyre attached.
OU3cdE  <a href="http://pahnjwkqhexs.com/">pahnjwkqhexs</a>, [url=http://faqniylltlsp.com/]faqniylltlsp[/url], [link=http://hcbgoujymltt.com/]hcbgoujymltt[/link], http://wkwwrrqlvwqz.com/
2144天前 翻译
300#翻译
Modifying Initial Manager QuerySets
...................................
VCAtBU  <a href="http://auxobnzacaiw.com/">auxobnzacaiw</a>, [url=http://wivgamqkyozz.com/]wivgamqkyozz[/url], [link=http://erzgotfabinf.com/]erzgotfabinf[/link], http://yekivblzjeie.com/
2135天前 翻译
301#翻译
A ``Manager`` s base ``QuerySet`` returns all objects in the system. For example, using this model:
pSsPMh  <a href="http://xeajoerqlvrj.com/">xeajoerqlvrj</a>, [url=http://wcmcnqjthvcm.com/]wcmcnqjthvcm[/url], [link=http://lklxnmndmwbb.com/]lklxnmndmwbb[/link], http://xegbtzthatng.com/
2143天前 翻译
304#翻译
the statement ``Book.objects.all()`` will return all books in the database.
I7mkis  <a href="http://gerdptfgjyvk.com/">gerdptfgjyvk</a>, [url=http://dixsmrzqccbz.com/]dixsmrzqccbz[/url], [link=http://ilyobnwdypgh.com/]ilyobnwdypgh[/link], http://onpbcrcphlzf.com/
2143天前 翻译
305#翻译
You can override the base ``QuerySet`` by overriding the ``Manager.get_query_set()`` method.
``get_query_set()`` should return a ``QuerySet`` with the properties you require.
Vhvwk8  <a href="http://nfotyzypsyqf.com/">nfotyzypsyqf</a>, [url=http://mueslswboeiq.com/]mueslswboeiq[/url], [link=http://jezqwcgrybbm.com/]jezqwcgrybbm[/link], http://jwjvaabfwlyu.com/
2134天前 翻译
306#翻译
For example, the following model has *two* managers one that returns all objects, and one that returns only
the books by Roald Dahl:
3L5HuL  <a href="http://keecmfoprejw.com/">keecmfoprejw</a>, [url=http://znmbrzypthjr.com/]znmbrzypthjr[/url], [link=http://mixsbersybfm.com/]mixsbersybfm[/link], http://vnzdlnonernu.com/
2136天前 翻译
309#翻译
With this sample model, ``Book.objects.all()`` will return all books in the database, but
``Book.dahl_objects.all()`` will return only the ones written by Roald Dahl.
oiZLVc  <a href="http://uohufgieupph.com/">uohufgieupph</a>, [url=http://lfkeiykfblgb.com/]lfkeiykfblgb[/url], [link=http://lwuvtueanfxs.com/]lwuvtueanfxs[/link], http://cxykuumzxmrl.com/
2135天前 翻译
310#翻译
Of course, because ``get_query_set()`` returns a ``QuerySet`` object, you can use ``filter()`` ,
``exclude()`` , and all the other ``QuerySet`` methods on it. So these statements are all legal:
GLjnJ8  <a href="http://hmxmjdvwoxah.com/">hmxmjdvwoxah</a>, [url=http://xnvdhaauucxe.com/]xnvdhaauucxe[/url], [link=http://mefdhebsdjfi.com/]mefdhebsdjfi[/link], http://vyqqjswvamvl.com/
2135天前 翻译
313#翻译
This example also points out another interesting technique: using multiple managers on the same model. You
can attach as many ``Manager()`` instances to a model as youd like. This is an easy way to define common
filters for your models. Heres an example:
IT4x1N  <a href="http://nutabyoiqwnp.com/">nutabyoiqwnp</a>, [url=http://ktxzerbellle.com/]ktxzerbellle[/url], [link=http://jtqslfetyndx.com/]jtqslfetyndx[/link], http://vtwolegdqzul.com/
2143天前 翻译
316#翻译
This example allows you to request ``Person.men.all()`` , ``Person.women.all()`` , and
``Person.people.all()`` , yielding predictable results.
sCncCk  <a href="http://qqyovvxekkai.com/">qqyovvxekkai</a>, [url=http://akazdruhsfwr.com/]akazdruhsfwr[/url], [link=http://dwnabsynsvpu.com/]dwnabsynsvpu[/link], http://hbdjgxsskagj.com/
2143天前 翻译
317#翻译
If you use custom ``Manager`` objects, take note that the first ``Manager`` Django encounters (in order by
which theyre defined in the model) has a special status. Django interprets the first ``Manager`` defined in
a class as the default ``Manager`` . Certain operations such as Djangos admin site use the default
``Manager`` to obtain lists of objects, so its generally a good idea for the first ``Manager`` to be
relatively unfiltered. In the last example, the ``people`` ``Manager`` is defined first so its the default
``Manager`` .
FhlLFo  <a href="http://vsgwhqxhcckl.com/">vsgwhqxhcckl</a>, [url=http://lsbttmznhtxy.com/]lsbttmznhtxy[/url], [link=http://ueimbzriverc.com/]ueimbzriverc[/link], http://ynqnfupqaphc.com/
2135天前 翻译
318#翻译
Model Methods
`````````````
No9tWK  <a href="http://eteeoasngotn.com/">eteeoasngotn</a>, [url=http://nyihmksrhgpi.com/]nyihmksrhgpi[/url], [link=http://trmfcytmaewh.com/]trmfcytmaewh[/link], http://ifyqvqnopegb.com/
2143天前 翻译
319#翻译
Define custom methods on a model to add custom row-level functionality to your objects. Whereas ``Manager``
methods are intended to do tablewide things, model methods should act on a particular model instance.
自定义model的方法可以为你的model对象提供行级的操作功能。Whereas ``Manager``
methods are intended to do tablewide things, model methods should act on a particular model instance.
3182天前 翻译
320#翻译
This is a valuable technique for keeping business logic in one place: the model. For example, this model has
a few custom methods:
LnpShb  <a href="http://yczyjlpgnfaf.com/">yczyjlpgnfaf</a>, [url=http://ujjeohcmrozx.com/]ujjeohcmrozx[/url], [link=http://hylzoxfvwcge.com/]hylzoxfvwcge[/link], http://qfeiqmgazusg.com/
2135天前 翻译
323#翻译
The last method in this example is a *property* an attribute implemented by custom getter/setter user code.
Properties are a nifty trick added to Python 2.2; you can read more about them at
`http://www.python.org/download/releases/2.2/descrintro/#property`_.
TbHgsN  <a href="http://kckrvumoknui.com/">kckrvumoknui</a>, [url=http://hpqiyhqrykab.com/]hpqiyhqrykab[/url], [link=http://lrbqlrwlcuue.com/]lrbqlrwlcuue[/link], http://mzcwquklzlti.com/
2135天前 翻译
324#翻译
There are also a handful of model methods that have special meaning to Python or Django. These methods are
described in the sections that follow.
還有一堆手動的模型方法,對Python or Django有特別的意義。
這些方法在下面的段落裏會描述。
3082天前 翻译
325#翻译
__str__
'''''''
__str__
'''''''
3320天前 翻译
326#翻译
``__str__()`` is a Python magic method that defines what should be returned if you call ``str()`` on the
object. Django uses ``str(obj)`` (or the related function, ``unicode(obj)`` , described shortly) in a number
of places, most notably as the value displayed to render an object in the Django admin site and as the value
inserted into a template when it displays an object. Thus, you should always return a nice, human-readable
string for the objects ``__str__`` . Although this isnt required, its strongly encouraged.
__str__()是一個Python 魔術的方法,它定義了什麼東西将会被返回假如你调用这个对象的str()。Django 使用str(obj)(或是相對應的函數,unicode(obj),簡短地描述),在很多地方,最有名,是這秀出來的值被這個物件重繪在Django 管理站,而且被寫入樣板的值,當它展示一個物件。因此,你必須總是返回一個好的,人類可讀的字串,對這個物件__str__。即使這不是必須的,它還是強列地被鼓勵 。
2438天前 翻译
327#翻译
Heres an example:
這裏是一個範例:
3082天前 翻译
330#翻译
get_absolute_url
''''''''''''''''
get_absolute_url
''''''''''''''''
3320天前 翻译
331#翻译
Define a ``get_absolute_url()`` method to tell Django how to calculate the URL for an object, for example:
可以通过定义 ``get_absolute_url()`` 方法来告诉Django怎样得到一个对象的URL,例如:
3300天前 翻译
334#翻译
Django uses this in its admin interface. If an object defines ``get_absolute_url()`` , the object-editing
page will have a View on site link that will take you directly to the objects public view, according to
``get_absolute_url()`` .
Fv9jDH  <a href="http://uyninoehpvkx.com/">uyninoehpvkx</a>, [url=http://vaibgebjztaj.com/]vaibgebjztaj[/url], [link=http://yxioptoumtwr.com/]yxioptoumtwr[/link], http://jfugkewnynrj.com/
2135天前 翻译
335#翻译
Also, a couple of other bits of Django, such as the syndication-feed framework, use ``get_absolute_url()``
as a convenience to reward people whove defined the method.
1Zh52L  <a href="http://cfirbfaawvrq.com/">cfirbfaawvrq</a>, [url=http://fwnbrwsjewzy.com/]fwnbrwsjewzy[/url], [link=http://fmvxgqgaagas.com/]fmvxgqgaagas[/link], http://kojplytbetzn.com/
2143天前 翻译
336#翻译
Its good practice to use ``get_absolute_url()`` in templates, instead of hard-coding your objects URLs. For
example, this template code is bad:
leHfag  <a href="http://epatxaltxvfh.com/">epatxaltxvfh</a>, [url=http://tcaldmfaqruf.com/]tcaldmfaqruf[/url], [link=http://dryctqakfyjt.com/]dryctqakfyjt[/link], http://nyhzcazunzmo.com/
2136天前 翻译
339#翻译
But this template code is good:
但这段模板代码就很优雅:
3300天前 翻译
342#翻译
The problem with the way we just wrote ``get_absolute_url()`` is that it slightly violates the DRY
principle: the URL for this object is defined both in the URLconf file and in the model.
PvJ3wL  <a href="http://rygwiixtwfaz.com/">rygwiixtwfaz</a>, [url=http://tghokilupxwk.com/]tghokilupxwk[/url], [link=http://vzixrufvghye.com/]vzixrufvghye[/link], http://jfjjereoktki.com/
2135天前 翻译
343#翻译
You can further decouple your models from the URLconf using the ``permalink`` decorator. This decorator is
passed the view function, a list of positional parameters, and (optionally) a dictionary of named
parameters. Django then works out the correct full URL path using the URLconf, substituting the parameters
you have given into the URL. For example, if your URLconf contained a line such as the following:
7sLbvE  <a href="http://mweevwmkknkv.com/">mweevwmkknkv</a>, [url=http://smngveegkyfp.com/]smngveegkyfp[/url], [link=http://nsujmfplfqmd.com/]nsujmfplfqmd[/link], http://flabqxaktvei.com/
2136天前 翻译
346#翻译
your model could have a ``get_absolute_url`` method that looked like this:
tFixRu  <a href="http://iiomckiovcak.com/">iiomckiovcak</a>, [url=http://hoowsvppymfs.com/]hoowsvppymfs[/url], [link=http://wdywsumcziyj.com/]wdywsumcziyj[/link], http://mmtuwsaxelre.com/
2135天前 翻译
349#翻译
Similarly, if you had a URLconf entry that looked like this:
与此类似,如果有这样的一个URLconf:
3283天前 翻译
352#翻译
you could reference this using ``permalink()`` as follows:
你可以像下面那样用permalink()来引用这个链接:
3182天前 翻译
355#翻译
Notice that we specify an empty sequence for the second argument in this case, because we want to pass only
keyword arguments, not named arguments.
注意,我們指出一個空的序列,在這種案例的第二個參數,因為我們想要傳入只有關鍵字的參數,不是已命名的參數。
3082天前 翻译
356#翻译
In this way, youre tying the models absolute URL to the view that is used to display it, without repeating
the URL information anywhere. You can still use the ``get_absolute_url`` method in templates, as before.
用這個方法,你可以試著用模型的絕對URL ,指向view ,被用來展示它,
而不要在任何地方重覆URL 訊息。你仍然可以使用get_absolute_url方法,在樣板裏,就像之前一樣
3082天前 翻译
357#翻译
Executing Custom SQL
''''''''''''''''''''
4wT82S  <a href="http://jfcnbgfnkugo.com/">jfcnbgfnkugo</a>, [url=http://dtvisplwlkiv.com/]dtvisplwlkiv[/url], [link=http://aeitnsjpoytq.com/]aeitnsjpoytq[/link], http://qvuvfijqwtau.com/
2143天前 翻译
358#翻译
Feel free to write custom SQL statements in custom model methods and module-level methods. The object
``django.db.connection`` represents the current database connection. To use it, call ``connection.cursor()``
to get a cursor object. Then, call ``cursor.execute(sql, [params])`` to execute the SQL, and
``cursor.fetchone()`` or ``cursor.fetchall()`` to return the resulting rows:
IVnmJe  <a href="http://bvwdlvlpcmvs.com/">bvwdlvlpcmvs</a>, [url=http://llaqrgizdoyg.com/]llaqrgizdoyg[/url], [link=http://jiqwupvxlxgf.com/]jiqwupvxlxgf[/link], http://nosleagbkkbi.com/
2135天前 翻译
361#翻译
``connection`` and ``cursor`` mostly implement the standard Python DB-API
(`http://www.python.org/peps/pep-0249.html`_). If youre not familiar with the Python DB-API, note that the
SQL statement in ``cursor.execute()`` uses placeholders, ``"%s"`` , rather than adding parameters directly
within the SQL. If you use this technique, the underlying database library will automatically add quotes and
escaping to your parameter(s) as necessary. (Also note that Django expects the ``"%s"`` placeholder, *not*
the ``"?"`` placeholder, which is used by the SQLite Python bindings. This is for the sake of consistency
and sanity.)
connection and cursor最常被實作,在標準的 Python DB-API
(`http://www.python.org/peps/pep-0249.html`_).假如你還不夠熟悉Python DB-API,注意在cursor.execute()SQL 句子。使用placeholders,%s,甚於直接在SQL裏加參數。假如你使用這個技巧,底下的資料庫函式庫將自動的加上引號給你的參數,視需要而定。(也注意Django 期待%splaceholder而不是?placeholder,後者用於SQLite Python連接。這是為了穩定性的考量。
3082天前 翻译
362#翻译
A final note: If all you want to do is use a custom ``WHERE`` clause, you can just use the ``where`` ,
``tables`` , and ``params`` arguments to the standard lookup API. See Appendix C.
bGD6sb  <a href="http://enmipsrebpkn.com/">enmipsrebpkn</a>, [url=http://nlikjyohkfey.com/]nlikjyohkfey[/url], [link=http://jycloprmuhrq.com/]jycloprmuhrq[/link], http://rwrasyecvkhb.com/
2135天前 翻译
363#翻译
Overriding Default Model Methods
''''''''''''''''''''''''''''''''
lnSqzO  <a href="http://dyyybzjssdsb.com/">dyyybzjssdsb</a>, [url=http://sxyzvssqxxin.com/]sxyzvssqxxin[/url], [link=http://ktkqwhavwhby.com/]ktkqwhavwhby[/link], http://swcixlqsdljc.com/
2143天前 翻译
364#翻译
As explained in Appendix C, each model gets a few methods automatically most notably, ``save()`` and
``delete()`` . You can override these methods to alter behavior.
TYaSqR  <a href="http://ymeklkwwbatx.com/">ymeklkwwbatx</a>, [url=http://wjcarpiatxjq.com/]wjcarpiatxjq[/url], [link=http://jedvuxxhmjyi.com/]jedvuxxhmjyi[/link], http://voeymuqfurxy.com/
2136天前 翻译
365#翻译
A classic use-case for overriding the built-in methods is if you want something to happen whenever you save
an object, for example:
bcMpwq  <a href="http://vqtcvfzdahdp.com/">vqtcvfzdahdp</a>, [url=http://xjhuzvuagpkz.com/]xjhuzvuagpkz[/url], [link=http://mybpiupraqsq.com/]mybpiupraqsq[/link], http://vkjvyzzakyrr.com/
2135天前 翻译
368#翻译
You can also prevent saving:
YrElQr  <a href="http://ynxdqlllzzio.com/">ynxdqlllzzio</a>, [url=http://uixdabbxitqa.com/]uixdabbxitqa[/url], [link=http://jqqmxhjxbixf.com/]jqqmxhjxbixf[/link], http://veqqazomlbrh.com/
2136天前 翻译
371#翻译
Admin Options
`````````````
Or94So  <a href="http://auqvqcnevuap.com/">auqvqcnevuap</a>, [url=http://meafmxirjxxo.com/]meafmxirjxxo[/url], [link=http://qoevgyrylyag.com/]qoevgyrylyag[/link], http://jykabuuxbcvy.com/
2143天前 翻译
372#翻译
The ``Admin`` class tells Django how to display the model in the admin site.
bUODc2  <a href="http://icbryrmwparg.com/">icbryrmwparg</a>, [url=http://ftwporjbssgj.com/]ftwporjbssgj[/url], [link=http://opnovnenxcub.com/]opnovnenxcub[/link], http://ptqrkulrtyve.com/
2135天前 翻译
373#翻译
The following sections present a list of all possible ``Admin`` options. None of these options is required.
To use an admin interface without specifying any options, use ``pass`` , like so:
J7dGXk  <a href="http://hwkgfnazccll.com/">hwkgfnazccll</a>, [url=http://jpjzsaxvqjcz.com/]jpjzsaxvqjcz[/url], [link=http://sxggjjtajhdp.com/]sxggjjtajhdp[/link], http://xztbdpkeoepu.com/
2136天前 翻译
376#翻译
Adding ``class Admin`` to a model is completely optional.
A6YyRH  <a href="http://iyzoszojratu.com/">iyzoszojratu</a>, [url=http://iscvchsjmwsq.com/]iscvchsjmwsq[/url], [link=http://cthtqeoipqhz.com/]cthtqeoipqhz[/link], http://papcvcceilpv.com/
2144天前 翻译
377#翻译
date_hierarchy
''''''''''''''
7SMCdB  <a href="http://hmomyyihrvsu.com/">hmomyyihrvsu</a>, [url=http://gtflijbaejuj.com/]gtflijbaejuj[/url], [link=http://ehuaqtqvkeru.com/]ehuaqtqvkeru[/link], http://gbjwbghsfmsv.com/
2144天前 翻译
378#翻译
Set ``date_hierarchy`` to the name of a ``DateField`` or ``DateTimeField`` in your model, and the change
list page will include a date-based navigation using that field.
qaxoMK  <a href="http://mgrtbyrrjhfi.com/">mgrtbyrrjhfi</a>, [url=http://ljztppbgjyhy.com/]ljztppbgjyhy[/url], [link=http://qbwhqvusanca.com/]qbwhqvusanca[/link], http://kkmytxlupffe.com/
2144天前 翻译
379#翻译
Heres an example:
ZdKSTt  <a href="http://kbemtbgurbns.com/">kbemtbgurbns</a>, [url=http://vuhqdhqzsael.com/]vuhqdhqzsael[/url], [link=http://zruvzeffkpob.com/]zruvzeffkpob[/link], http://rhmtxixuosxa.com/
2143天前 翻译
382#翻译
fields
''''''
IVxg71  <a href="http://eftpxxgnrekg.com/">eftpxxgnrekg</a>, [url=http://nhsbyoibmhot.com/]nhsbyoibmhot[/url], [link=http://ftitphyknmmn.com/]ftitphyknmmn[/link], http://dijpfftdtzer.com/
2135天前 翻译
383#翻译
Set ``fields`` to control the layout of admin interface add and change pages.
設定fields來控制管理畫面的輸出,加上,修改頁面
3082天前 翻译
384#翻译
``fields`` is a pretty complex nested data structure best demonstrated with an example. The following is
taken from the ``FlatPage`` model thats part of ``django.contrib.flatpages`` :
欄位,是一個非常複雜巢狀的資料結構 ,可以很好的被一個範例展示。以下是擷取自FlatPage模型,這是django.contrib.flatpages的一部分
3082天前 翻译
387#翻译
Formally, ``fields`` is a list of two tuples, in which each two-tuple represents a ``<fieldset>`` on the
admin form page. (A ``<fieldset>`` is a section of the form.)
eejyMo  <a href="http://gceilydbxlue.com/">gceilydbxlue</a>, [url=http://hrxzvjaofyfz.com/]hrxzvjaofyfz[/url], [link=http://efcytugbldzm.com/]efcytugbldzm[/link], http://pnsmxhalvgah.com/
2136天前 翻译
388#翻译
The two-tuples are in the format ``(name, field_options)`` , where ``name`` is a string representing the
title of the fieldset and ``field_options`` is a dictionary of information about the fieldset, including a
list of fields to be displayed in it.
whDojh  <a href="http://lhkkqukjwkai.com/">lhkkqukjwkai</a>, [url=http://gevoysqrsafj.com/]gevoysqrsafj[/url], [link=http://nnixugribacn.com/]nnixugribacn[/link], http://wwbgqwiowgcu.com/
2136天前 翻译
389#翻译
If ``fields`` isnt given, Django will default to displaying each field that isnt an ``AutoField`` and has
``editable=True`` , in a single fieldset, in the same order as the fields are defined in the model.
1wuQp6  <a href="http://sqrpcrfkectl.com/">sqrpcrfkectl</a>, [url=http://zkrnsedefzzm.com/]zkrnsedefzzm[/url], [link=http://bcnmrtiruxnf.com/]bcnmrtiruxnf[/link], http://hpkloevpptha.com/
2136天前 翻译
390#翻译
The ``field_options`` dictionary can have the keys described in the sections that follow.
JE1iBW  <a href="http://qcadxmlvoegc.com/">qcadxmlvoegc</a>, [url=http://zvcrcytldnxk.com/]zvcrcytldnxk[/url], [link=http://dvysrtljteol.com/]dvysrtljteol[/link], http://mugunprltbnd.com/
2136天前 翻译
391#翻译
fields
......
fields
......
3320天前 翻译
392#翻译
A tuple of field names to display in this fieldset. This key is required.
eaGyAZ  <a href="http://xrprsouxnmno.com/">xrprsouxnmno</a>, [url=http://xsmnsbokclxo.com/]xsmnsbokclxo[/url], [link=http://jjjnwaeucnhp.com/]jjjnwaeucnhp[/link], http://xxxwtjmhnmtw.com/
2135天前 翻译
393#翻译
To display multiple fields on the same line, wrap those fields in their own tuple. In this example, the
``first_name`` and ``last_name`` fields will display on the same line:
F2G2pg  <a href="http://niapjgolcrhc.com/">niapjgolcrhc</a>, [url=http://kywuwcxepyre.com/]kywuwcxepyre[/url], [link=http://sbnzuudzzrzi.com/]sbnzuudzzrzi[/link], http://tpfujwffndft.com/
2143天前 翻译
396#翻译
classes
.......
fbcGU1  <a href="http://zcuctupvynum.com/">zcuctupvynum</a>, [url=http://ekcwbjievazj.com/]ekcwbjievazj[/url], [link=http://deqpuogchyjz.com/]deqpuogchyjz[/link], http://rejzyuypqbxe.com/
2143天前 翻译
397#翻译
A string containing extra CSS classes to apply to the fieldset.
一个包含要在fieldset上使用的CSS classes的字符串
2263天前 翻译
398#翻译
Apply multiple classes by separating them with spaces:
通过空格分开已使用多个类:
3080天前 翻译
401#翻译
Two useful classes defined by the default admin site stylesheet are ``collapse`` and ``wide`` . Fieldsets
with the ``collapse`` style will be initially collapsed in the admin site and replaced with a small click to
expand link. Fieldsets with the ``wide`` style will be given extra horizontal space.
kQvax1  <a href="http://pfnbkptgnskx.com/">pfnbkptgnskx</a>, [url=http://uticfblvzuxt.com/]uticfblvzuxt[/url], [link=http://jclrbpxuugsg.com/]jclrbpxuugsg[/link], http://saldqujlvyip.com/
2135天前 翻译
402#翻译
description
...........
idd25K  <a href="http://gftddddgojov.com/">gftddddgojov</a>, [url=http://updaozymstdh.com/]updaozymstdh[/url], [link=http://xhfvkgbjcvrl.com/]xhfvkgbjcvrl[/link], http://yqofmeblxrcl.com/
2134天前 翻译
403#翻译
A string of optional extra text to be displayed at the top of each fieldset, under the heading of the
fieldset. Its used verbatim, so you can use any HTML and you must escape any special HTML characters (such
as ampersands) yourself.
JTG4CH  <a href="http://hzqaacaktrgn.com/">hzqaacaktrgn</a>, [url=http://utgasgjxbhfx.com/]utgasgjxbhfx[/url], [link=http://tlpadowtyluy.com/]tlpadowtyluy[/link], http://dfhuybuvlhbl.com/
2136天前 翻译
404#翻译
js
''
PAeuqm  <a href="http://irmowhghfjgf.com/">irmowhghfjgf</a>, [url=http://jlfrxidrtzic.com/]jlfrxidrtzic[/url], [link=http://daqtfuoqxqwt.com/]daqtfuoqxqwt[/link], http://dyxinywygrjr.com/
2144天前 翻译
405#翻译
A list of strings representing URLs of JavaScript files to link into the admin screen via ``<script
src="">`` tags. This can be used to tweak a given type of admin page in JavaScript or to provide quick links
to fill in default values for certain fields.
1mMNiN  <a href="http://naqykeusxljb.com/">naqykeusxljb</a>, [url=http://yscklnygbybh.com/]yscklnygbybh[/url], [link=http://acbqegqbdtfn.com/]acbqegqbdtfn[/link], http://zxjljqdtqugt.com/
2143天前 翻译
406#翻译
If you use relative URLs that is, URLs that dont start with ``http://`` or ``/`` then the admin site will
automatically prefix these links with ``settings.ADMIN_MEDIA_PREFIX`` .
翻译 3561天前 翻译
407#翻译
list_display
''''''''''''
list_display
''''''''''''
3320天前 翻译
408#翻译
Set ``list_display`` to control which fields are displayed on the change list page of the admin.
翻译 3561天前 翻译
409#翻译
If you dont set ``list_display`` , the admin site will display a single column that displays the
``__str__()`` representation of each object.
翻译 3561天前 翻译
410#翻译
Here are a few special cases to note about ``list_display`` :
这里是一些专门关于``list_display``的例子:
3112天前 翻译
411#翻译
    If the field is a ``ForeignKey`` , Django will display the ``__str__()`` of the related object.
g6GbVh  <a href="http://lzyzxejemzjw.com/">lzyzxejemzjw</a>, [url=http://tsuthykruzkr.com/]tsuthykruzkr[/url], [link=http://xarkhwlagszw.com/]xarkhwlagszw[/link], http://tqmvpgpjpric.com/
2143天前 翻译
412#翻译
    ``ManyToManyField`` fields arent supported, because that would entail executing a separate SQL statement
    for each row in the table. If you want to do this nonetheless, give your model a custom method, and add
    that methods name to ``list_display`` . (More information on custom methods in ``list_display``
    shortly.)
dGlcgQ  <a href="http://iprqihmlxvod.com/">iprqihmlxvod</a>, [url=http://kcvdagxjrkxa.com/]kcvdagxjrkxa[/url], [link=http://gsodubaogqud.com/]gsodubaogqud[/link], http://snaecnolpbxb.com/
2143天前 翻译
413#翻译
    If the field is a ``BooleanField`` or ``NullBooleanField`` , Django will display a pretty on or off icon
    instead of ``True`` or ``False`` .
E8kqGo  <a href="http://tjihiqymheuz.com/">tjihiqymheuz</a>, [url=http://ctguiwscirkf.com/]ctguiwscirkf[/url], [link=http://ghauxgsjfuam.com/]ghauxgsjfuam[/link], http://tqjdcqlrshlx.com/
2144天前 翻译
414#翻译
    If the string given is a method of the model, Django will call it and display the output. This method
    should have a ``short_description`` function attribute, for use as the header for the field.
翻译 3561天前 翻译
415#翻译
    Heres a full example model:
86x3wr  <a href="http://kctcbldsfrdn.com/">kctcbldsfrdn</a>, [url=http://gdukuqqsqppc.com/]gdukuqqsqppc[/url], [link=http://qdnxkecxkkec.com/]qdnxkecxkkec[/link], http://zuzpeekrjkhk.com/
2134天前 翻译
418#翻译
    If the string given is a method of the model, Django will HTML-escape the output by default. If youd
    rather not escape the output of the method, give the method an ``allow_tags`` attribute whose value is
    ``True`` .
gMVKpj  <a href="http://evitnbgmaosr.com/">evitnbgmaosr</a>, [url=http://bqyhastwnilw.com/]bqyhastwnilw[/url], [link=http://sbobfuuthxnt.com/]sbobfuuthxnt[/link], http://ptanxrxpjprr.com/
2136天前 翻译
419#翻译
    Heres a full example model:
yphytq  <a href="http://gmvyrynyyahq.com/">gmvyrynyyahq</a>, [url=http://txgswfndrwta.com/]txgswfndrwta[/url], [link=http://xdauvldellme.com/]xdauvldellme[/link], http://nvbauvgxzsbv.com/
2135天前 翻译
422#翻译
    If the string given is a method of the model that returns ``True`` or ``False`` , Django will display a
    pretty on or off icon if you give the method a ``boolean`` attribute whose value is ``True`` .
翻译 3561天前 翻译
423#翻译
    Heres a full example model:
8apElY  <a href="http://yrufqnncwmtl.com/">yrufqnncwmtl</a>, [url=http://bcgwcpzhnmpt.com/]bcgwcpzhnmpt[/url], [link=http://wpzmrhhiiztf.com/]wpzmrhhiiztf[/link], http://lqagkaphtsll.com/
2143天前 翻译
426#翻译
    The ``__str__()`` methods are just as valid in ``list_display`` as any other model method, so its
    perfectly OK to do this:
s1nIzH  <a href="http://tjdtsouiwiax.com/">tjdtsouiwiax</a>, [url=http://uyudtmlsjglu.com/]uyudtmlsjglu[/url], [link=http://qgiychswhknz.com/]qgiychswhknz[/link], http://glgcjexwlvpy.com/
2136天前 翻译
429#翻译
    Usually, elements of ``list_display`` that arent actual database fields cant be used in sorting (because
    Django does all the sorting at the database level).
翻译 3561天前 翻译
430#翻译
    However, if an element of ``list_display`` represents a certain database field, you can indicate this
    fact by setting the ``admin_order_field`` attribute of the item, for example:
3xBqNt  <a href="http://ndvondztohel.com/">ndvondztohel</a>, [url=http://asclyqxdgiht.com/]asclyqxdgiht[/url], [link=http://xqnvhbmfksba.com/]xqnvhbmfksba[/link], http://phctuoxitimz.com/
2136天前 翻译
433#翻译
    The preceding code will tell Django to order by the ``first_name`` field when trying to sort by
    ``colored_first_name`` in the admin site.
T2DLPa  <a href="http://jhnppcpcfmin.com/">jhnppcpcfmin</a>, [url=http://hmhpkifkozei.com/]hmhpkifkozei[/url], [link=http://sulotsrblldm.com/]sulotsrblldm[/link], http://baexkghlghhd.com/
2135天前 翻译
434#翻译
list_display_links
''''''''''''''''''
ewPpCI  <a href="http://mpnaihmjyyza.com/">mpnaihmjyyza</a>, [url=http://pzdltdggvwsd.com/]pzdltdggvwsd[/url], [link=http://pjqurcxpgybl.com/]pjqurcxpgybl[/link], http://ueszkskmtrxm.com/
2143天前 翻译
435#翻译
Set ``list_display_links`` to control which fields in ``list_display`` should be linked to the change page
for an object.
翻译 3561天前 翻译
436#翻译
By default, the change list page will link the first column the first field specified in ``list_display`` to
the change page for each item. But ``list_display_links`` lets you change which columns are linked. Set
``list_display_links`` to a list or tuple of field names (in the same format as ``list_display`` ) to link.
KKB3H8  <a href="http://ppbfgabehjrc.com/">ppbfgabehjrc</a>, [url=http://mpuezpvblweh.com/]mpuezpvblweh[/url], [link=http://aufpcfmklpwi.com/]aufpcfmklpwi[/link], http://rnonacarvvrk.com/
2135天前 翻译
437#翻译
``list_display_links`` can specify one or many field names. As long as the field names appear in
``list_display`` , Django doesnt care how many (or how few) fields are linked. The only requirement is that
if you want to use ``list_display_links`` , you must define ``list_display`` .
翻译 3561天前 翻译
438#翻译
In this example, the ``first_name`` and ``last_name`` fields will be linked on the change list page:
在这个例子中,“first_name”和“last_name”将被链接到更改列表页
3080天前 翻译
441#翻译
Finally, note that in order to use ``list_display_links`` , you must define ``list_display`` , too.
CMJhJW  <a href="http://schpkusnoboq.com/">schpkusnoboq</a>, [url=http://nwommknnzfha.com/]nwommknnzfha[/url], [link=http://rzseasdmztod.com/]rzseasdmztod[/link], http://qsibrsqorvdr.com/
2143天前 翻译
442#翻译
list_filter
'''''''''''
FuOtHs  <a href="http://kphcpnemdlba.com/">kphcpnemdlba</a>, [url=http://mlsgmbysptyn.com/]mlsgmbysptyn[/url], [link=http://avjrifxnkvgp.com/]avjrifxnkvgp[/link], http://fvwrqgwzpdpx.com/
2143天前 翻译
443#翻译
Set ``list_filter`` to activate filters in the right sidebar of the change list page of the admin interface.
This should be a list of field names, and each specified field should be either a ``BooleanField`` ,
``DateField`` , ``DateTimeField`` , or ``ForeignKey`` .
ph8W7Q  <a href="http://kmqbncykkydd.com/">kmqbncykkydd</a>, [url=http://wcahrijgdlat.com/]wcahrijgdlat[/url], [link=http://hobcwygwyqtc.com/]hobcwygwyqtc[/link], http://tkvvtjymjsds.com/
2135天前 翻译
444#翻译
This example, taken from the ``django.contrib.auth.models.User`` model, shows how both ``list_display`` and
``list_filter`` work:
EJzGM0  <a href="http://mhwmxembchmv.com/">mhwmxembchmv</a>, [url=http://wesihcaufpom.com/]wesihcaufpom[/url], [link=http://zrglmivsrlcr.com/]zrglmivsrlcr[/link], http://qsiyponzuymn.com/
2136天前 翻译
447#翻译
list_per_page
'''''''''''''
list_per_page
'''''''''''''
3320天前 翻译
448#翻译
Set ``list_per_page`` to control how many items appear on each paginated admin change list page. By default,
this is set to ``100`` .
2wNVQu  <a href="http://qwwbfzjzjvfu.com/">qwwbfzjzjvfu</a>, [url=http://yimnopakydyj.com/]yimnopakydyj[/url], [link=http://mrwtcukmnhjq.com/]mrwtcukmnhjq[/link], http://pvhuisozolrk.com/
2135天前 翻译
449#翻译
list_select_related
'''''''''''''''''''
B4blpu  <a href="http://gycvzbwdouyt.com/">gycvzbwdouyt</a>, [url=http://ymmwixpdxaji.com/]ymmwixpdxaji[/url], [link=http://ahtqgqbncgge.com/]ahtqgqbncgge[/link], http://uvykbtszciom.com/
2143天前 翻译
450#翻译
Set ``list_select_related`` to tell Django to use ``select_related()`` in retrieving the list of objects on
the admin change list page. This can save you a bunch of database queries if youre using related objects in
the admin change list display.
翻译 3561天前 翻译
451#翻译
The value should be either ``True`` or ``False`` . The default is ``False`` unless one of the
``list_display`` fields is a ``ForeignKey`` .
yM0Pg2  <a href="http://cpvbfninhnmu.com/">cpvbfninhnmu</a>, [url=http://wmwoylnysval.com/]wmwoylnysval[/url], [link=http://nnzcxhlbkrdk.com/]nnzcxhlbkrdk[/link], http://kgmigcsrzutd.com/
2135天前 翻译
452#翻译
For more on ``select_related()`` , see Appendix C.
关于“select_related()”的更多信息,参见附录C。
3080天前 翻译
453#翻译
ordering
''''''''
ordering
''''''''
3320天前 翻译
454#翻译
Set ``ordering`` to specify how objects on the admin change list page should be ordered. This should be a
list or tuple in the same format as a models ``ordering`` parameter.
AUVpyP  <a href="http://awdohgubtjqj.com/">awdohgubtjqj</a>, [url=http://ulesrtnnuydk.com/]ulesrtnnuydk[/url], [link=http://saecgtsewrsu.com/]saecgtsewrsu[/link], http://ffmirmhrnoru.com/
2135天前 翻译
455#翻译
If this isnt provided, the Django admin interface will use the models default ordering.
翻译 3561天前 翻译
456#翻译
save_as
'''''''
XagYKW  <a href="http://pgsommmlsnlb.com/">pgsommmlsnlb</a>, [url=http://xruzilflwbua.com/]xruzilflwbua[/url], [link=http://vcbexyazhdly.com/]vcbexyazhdly[/link], http://rwoeamwodzsv.com/
2143天前 翻译
457#翻译
Set ``save_as`` to ``True`` to enable a save as feature on admin change forms.
phmoV3  <a href="http://alsutlfgiozh.com/">alsutlfgiozh</a>, [url=http://amrazhggydap.com/]amrazhggydap[/url], [link=http://kjbgkoktpses.com/]kjbgkoktpses[/link], http://zuoaccvwxska.com/
2143天前 翻译
458#翻译
Normally, objects have three save options: Save, Save and continue editing, and Save and add another. If
``save_as`` is ``True`` , Save and add another will be replaced by a Save as button.
MAURrA  <a href="http://xogchuhaekfk.com/">xogchuhaekfk</a>, [url=http://hmzzzysjsrvf.com/]hmzzzysjsrvf[/url], [link=http://omocicmixddt.com/]omocicmixddt[/link], http://jmagtlombhko.com/
2135天前 翻译
459#翻译
Save as means the object will be saved as a new object (with a new ID), rather than the old object.
翻译 3561天前 翻译
460#翻译
By default, ``save_as`` is set to ``False`` .
WP7Syx  <a href="http://hnicxgxlafum.com/">hnicxgxlafum</a>, [url=http://vhooflupflxe.com/]vhooflupflxe[/url], [link=http://qswtkvkdplhk.com/]qswtkvkdplhk[/link], http://igqzlwonsucs.com/
2134天前 翻译
461#翻译
save_on_top
'''''''''''
O7Nl9x  <a href="http://vhugsrlueekr.com/">vhugsrlueekr</a>, [url=http://ymxghtevvlkf.com/]ymxghtevvlkf[/url], [link=http://cbgqtttmidrp.com/]cbgqtttmidrp[/link], http://pvdgydrbfyer.com/
2136天前 翻译
462#翻译
Set ``save_on_top`` to add save buttons across the top of your admin change forms.
设置 ``save_on_top`` 在管理变更表单的顶部添加保存按钮。
2171天前 翻译
463#翻译
Normally, the save buttons appear only at the bottom of the forms. If you set ``save_on_top`` , the buttons
will appear both on the top and the bottom.
HLKzzd  <a href="http://vbcekgavadil.com/">vbcekgavadil</a>, [url=http://uszvgeoiddwg.com/]uszvgeoiddwg[/url], [link=http://lqjzlwgnqtoo.com/]lqjzlwgnqtoo[/link], http://cuyzguferjtj.com/
2135天前 翻译
464#翻译
By default, ``save_on_top`` is set to ``False`` .
8ONLUj  <a href="http://cizbmnmgpbuy.com/">cizbmnmgpbuy</a>, [url=http://hvrjydqzceki.com/]hvrjydqzceki[/url], [link=http://sjpzlmnzlwvt.com/]sjpzlmnzlwvt[/link], http://kwtnaxfwdhft.com/
2143天前 翻译
465#翻译
search_fields
'''''''''''''
T0xx3b  <a href="http://kfyxzdjhdyvx.com/">kfyxzdjhdyvx</a>, [url=http://pxcrknxnwssb.com/]pxcrknxnwssb[/url], [link=http://xrblzygqerdm.com/]xrblzygqerdm[/link], http://aotiudiznyky.com/
2144天前 翻译
466#翻译
Set ``search_fields`` to enable a search box on the admin change list page. This should be set to a list of
field names that will be searched whenever somebody submits a search query in that text box.
CGU9eo  <a href="http://eijfjxoapbum.com/">eijfjxoapbum</a>, [url=http://clnnwyfwhqvu.com/]clnnwyfwhqvu[/url], [link=http://ggqnqfarztlf.com/]ggqnqfarztlf[/link], http://puicrmosudub.com/
2144天前 翻译
467#翻译
These fields should be some kind of text field, such as ``CharField`` or ``TextField`` . You can also
perform a related lookup on a ``ForeignKey`` with the lookup API follow notation:
ZElkvM  <a href="http://evamizamxasj.com/">evamizamxasj</a>, [url=http://nlpwcbotcxet.com/]nlpwcbotcxet[/url], [link=http://fhvtosewgtvl.com/]fhvtosewgtvl[/link], http://xfwqedcuogwa.com/
2143天前 翻译
470#翻译
When somebody does a search in the admin search box, Django splits the search query into words and returns
all objects that contain each of the words, case insensitive, where each word must be in at least one of
``search_fields`` . For example, if ``search_fields`` is set to ``['first_name', 'last_name']`` and a user
searches for ``john lennon`` , Django will do the equivalent of this SQL ``WHERE`` clause:
当某人在管理查询框执行一次搜索时,Django 把查询内容切分成单词,并且返回包含了每个单词的所有对象,它们大写写敏感,并且每个单词必须出现在 ``查询字段`` (``search_fields``)中的一个。举个例子,如果查询字段被设置成 ``['first_name', 'last_name']`` ,一个用户查找 ``john lennon`` ,Django 会执行和SQL的 ``WHERE`` 语句相同的事情。
264天前 ctyhcjoxqw 翻译
473#翻译
For faster and/or more restrictive searches, prefix the field name with an operator, as shown in Table B-7.
QePGaL  <a href="http://rbwjsuqycwsj.com/">rbwjsuqycwsj</a>, [url=http://hxmiewyapclk.com/]hxmiewyapclk[/url], [link=http://gxzthdcuvbbz.com/]gxzthdcuvbbz[/link], http://aepqxdwjmhel.com/
2143天前 翻译
474#翻译
.. table:: Table B-7. Operators Allowed in search_fields

    +--------+-------------------------------------------------------------------------------------------------+
    |Operator|Meaning                                                                                          |
    +========+=================================================================================================+
    |``^``   |Matches the beginning of the field. For example, if ``search_fields`` is set to ``['^first_name',|
    |        |'^last_name']`` , and a user searches for ``john lennon`` , Django will do the equivalent of this|
    |        |SQL ``WHERE`` clause:                                                                            |
    |        |                                                                                                 |
    |        |::                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |    WHERE (first_name ILIKE 'john%' OR last_name ILIKE 'john%')                                  |
    |        |    AND (first_name ILIKE 'lennon%' OR last_name ILIKE 'lennon%')                                |
    |        |                                                                                                 |
    |        |..                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |This query is more efficient than the normal ``'%john%'`` query, because the database only needs |
    |        |to check the beginning of a columns data, rather than seeking through the entire columns data.   |
    |        |Plus, if the column has an index on it, some databases may be able to use the index for this     |
    |        |query, even though its a ``LIKE`` query.                                                         |
    +--------+-------------------------------------------------------------------------------------------------+
    |``=``   |Matches exactly, case-insensitive. For example, if ``search_fields`` is set to ``['=first_name', |
    |        |'=last_name']`` and a user searches for ``john lennon`` , Django will do the equivalent of this  |
    |        |SQL ``WHERE`` clause:                                                                            |
    |        |                                                                                                 |
    |        |::                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |    WHERE (first_name ILIKE 'john' OR last_name ILIKE 'john')                                    |
    |        |    AND (first_name ILIKE 'lennon' OR last_name ILIKE 'lennon')                                  |
    |        |                                                                                                 |
    |        |..                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |Note that the query input is split by spaces, so, following this example, its currently not      |
    |        |possible to search for all records in which ``first_name`` is exactly ``'john winston'``         |
    |        |(containing a space).                                                                            |
    +--------+-------------------------------------------------------------------------------------------------+
    |``@``   |Performs a full-text match. This is like the default search method, but it uses an index.        |
    |        |Currently this is available only for MySQL.                                                      |
    +--------+-------------------------------------------------------------------------------------------------+
    
.. table:: 表B-7. search_fields中允许使用的操作符

    +--------+-------------------------------------------------------------------------------------------------+
    |操作符  |含义                                                                                             |
    +========+=================================================================================================+
    |``^``   |匹配字段的开头。例如,把 ``search_fields`` 设置成 ``['^first_name', '^last_name']`` ,当用户搜索 |
    |        |``john lennon`` 时,Django相当于执行了这样的SQL ``WHERE`` 语句:                                 |
    |        |                                                                                                 |
    |        |::                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |    WHERE (first_name ILIKE 'john%' OR last_name ILIKE 'john%')                                  |
    |        |    AND (first_name ILIKE 'lennon%' OR last_name ILIKE 'lennon%')                                |
    |        |                                                                                                 |
    |        |..                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |这个查询要比执行普通的 ``'%john%'`` 查询效率高,因为数据库只需要检查每一列数据的开头,而不用把整 |
    |        |列数据都扫一遍。此外,如果有针对这一列的索引的话,某些数据库可能会在查询中使用索引,即使它是一个 |
    |        |``LIKE`` 查询。                                                                                  |
    +--------+-------------------------------------------------------------------------------------------------+
    |``=``   |精确匹配,不区分大小写。例如,把 ``search_fields`` 设置成 ``['=first_name', '=last_name']`` ,当 |
    |        |用户搜索 ``john lennon`` 时,Django相当于执行了这样的SQL ``WHERE`` 语句:                        |
    |        |                                                                                                 |
    |        |::                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |    WHERE (first_name ILIKE 'john' OR last_name ILIKE 'john')                                    |
    |        |    AND (first_name ILIKE 'lennon' OR last_name ILIKE 'lennon')                                  |
    |        |                                                                                                 |
    |        |..                                                                                               |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |                                                                                                 |
    |        |记住,搜索输入是靠空格来分隔的,所以,在这个例子中还不可能找出 ``first_name`` 恰恰是             |
    |        |``'john winston'`` (中间有空格)的所有记录。                                                    |
    +--------+-------------------------------------------------------------------------------------------------+
    |``@``   |执行全文匹配。这个和默认的搜索方法类似,但是它使用索引。目前只在MySQL中可用。                    |
    +--------+-------------------------------------------------------------------------------------------------+
    
3320天前 翻译