The Django Book

Appendix E: Settings

闄勫綍E 閰嶇疆鍙傝

Your Django settings file contains all the configuration of your Django installation. This appendix explains how settings work and which settings are available.

浣犵殑 Django 璁剧疆鏂囦欢鍖呭惈浜嗘墍鏈夌殑 Django 瀹夎閰嶇疆銆傛湰闄勫綍瑙i噴浜嗗浣曡缃幓浣垮畠宸ヤ綔浠ュ強鍝簺璁剧疆鏄湁鏁堢殑銆

Note

娉ㄦ剰

As Django grows, its occasionally necessary to add or (rarely) change settings. You should always check the online settings documentation at http://www.djangoproject.com/documentation/0.96/settings/ for the latest information.

闅忕潃Django鐨勫彂灞曪紝瀹冩湁鏃跺欓渶瑕佹坊鍔犳垨鏀瑰彉锛堝緢灏戯級涓浜泂ettings 锛屼綘搴旇缁忓父鍘绘煡鐪嬪湪绾跨殑settings 鏂囨。锛 http://www.djangoproject.com/documentation/0.96/settings/ 锛夛紝浜嗚В鏈鏂扮殑淇℃伅銆

Whats a Settings File?

浠涔堟槸settings鏂囦欢

A settings file is just a Python module with module-level variables.

涓涓 settings 鏂囦欢 鍙槸涓涓湁涓浜涙ā鍧楃骇鍙橀噺鐨凱ython妯″潡銆

Here are a couple of example settings:

杩欓噷鏄竴浜泂ettings渚嬪瓙锛

DEBUG = False
DEFAULT_FROM_EMAIL = 'webmaster@example.com'
TEMPLATE_DIRS = ('/home/templates/mike', '/home/templates/john')

Because a settings file is a Python module, the following apply:

鍥犱负涓涓猻ettings 鏂囦欢鏄竴涓猵ython妯″潡锛屽繀椤荤鍚堜笅闈㈢殑涓浜涚殑瑙勫垯锛

It must be valid Python code; syntax errors arent allowed.

瀹冨繀椤绘槸鍚堟硶鐨刾ython浠g爜锛屼笉鍏佽璇硶閿欒銆

It can assign settings dynamically using normal Python syntax, for example:

鍙互閫氳繃姝e父鐨刾ython璇硶缁檚ettings鍔ㄦ佽祴鍊硷紝姣斿锛

MY_SETTING = [str(i) for i in range(30)]

It can import values from other settings files.

瀹冨彲浠ヤ粠鍏朵粬settings 鏂囦欢瀵煎叆鍊笺

Default Settings

榛樿Settings

A Django settings file doesnt have to define any settings if it doesnt need to. Each setting has a sensible default value. These defaults live in the file django/conf/global_settings.py .

涓涓猟jango Settings鍙互涓虹┖,濡傛灉浣犱笉闇瑕佺殑璇濄傛瘡涓涓猄ettings鏈変竴涓垏鍚堝疄闄呯殑榛樿鍊硷紝杩欎簺榛樿鍊煎煎湪鏂囦欢 django/conf/global_settings.py 閲屻

Heres the algorithm Django uses in compiling settings:

涓嬮潰鏄痙jango鍦ㄧ紪璇憇ettings鏂囦欢鏃惰繍鐢ㄧ殑瑙勫垯锛

  • Load settings from global_settings.py .

  • global_settings.py 瑁呰浇settings .

  • Load settings from the specified settings file, overriding the global settings as necessary.

  • 浠庢寚瀹歴ettings 鏂囦欢瑁呰浇settings , 鍦ㄩ渶瑕佺殑鏃跺欙紝瑕嗙洊鍏ㄥ眬鐨剆ettings

Note that a settings file should not import from global_settings , because thats redundant.

娉ㄦ剰涓涓猻ettings 鏂囦欢涓嶅簲璇ュ鍏 global_settings 锛屽洜涓洪偅鏄浣欙紙鍐椾綑锛夌殑銆

Seeing Which Settings Youve Changed

鏌ョ湅浣犲凡缁忔敼鍙樹簡鍝簺Settings

Theres an easy way to view which of your settings deviate from the default settings. The command manage.py diffsettings displays differences between the current settings file and Djangos default settings.

鏈変竴涓鏄撶殑鏂规硶鏉ユ煡鐪嬩綘鐨勫摢浜汼ettings 鍜岄粯璁ょ殑Settings 涓嶅悓锛屽懡浠よ manage.py diffsettings 鍙互鏄剧ず褰撳墠鐨剆ettings 鏂囦欢鏂囦欢鍜岄粯璁ょ殑settings 鐨勪笉鍚屼箣澶勩

manage.py is described in more detail in Appendix G.

manage.py 鐨勬洿璇︾粏鎻忚堪鍦ㄩ檮褰旼锛

Using Settings in Python Code

鍦≒ython浠g爜涓娇Settings

In your Django applications, use settings by importing the object django.conf.settings , for example:

鍦ㄤ綘鐨凞jango搴旂敤绋嬪簭涓,浠庡璞 django.conf.settings 瀵煎叆settings浣跨敤锛屼緥濡:

from django.conf import settings

if settings.DEBUG:
    # Do something

Note that django.conf.settings isnt a module its an object. So importing individual settings is not possible:

娉ㄦ剰 django.conf.settings 涓嶆槸涓涓ā鍧楋紝鑰屾槸涓涓璞°傛墍浠ヤ笉鑳藉崟鐙鍏ettings锛

from django.conf.settings import DEBUG  # This won't work.

Also note that your code should not import from either global_settings or your own settings file. django.conf.settings abstracts the concepts of default settings and site-specific settings; it presents a single interface. It also decouples the code that uses settings from the location of your settings.

鍚屾牱瑕佹敞鎰忥紝浣犵殑浠g爜涓 搴旇瀵煎叆 global_settings 鎴栬呰嚜宸辩殑settings鏂囦欢銆 django.conf.settings 鎶借薄浜嗛粯璁ょ殑璁剧疆鍜屾瘡涓珯鐐圭殑璁剧疆锛涘畠鎻愪緵浜嗕竴涓崟涓鐨勬帴鍙c傚苟涓旓紝瀹冧篃浣垮緱浣犳墍鍐欑殑浠g爜涓庝綘鐨勮缃枃浠剁殑浣嶇疆娌℃湁鑰﹀悎銆

Altering Settings at Runtime

杩愯鏈熼棿淇敼Settings

You shouldnt alter settings in your applications at runtime. For example, dont do this in a view:

浣犱笉搴旇鍦ㄤ綘鐨勫簲鐢ㄧ▼搴忚繍琛屾湡闂翠慨鏀硅缃, 渚嬪, 涓嶈鍦╲iew閲岄潰鍋氳繖鏍风殑浜嬫儏:

from django.conf import settings

settings.DEBUG = True   # Don't do this!

The only place you should assign to settings is in a settings file.

settings鏂囦欢搴旇鏄敮涓涓慨鏀 settings 鐨勫湴鏂.

Security

瀹夊叏

Because a settings file contains sensitive information, such as the database password, you should make every attempt to limit access to it. For example, change its file permissions so that only you and your Web servers user can read it. This is especially important in a shared-hosting environment.

鍥犱负settings鏂囦欢鍖呭惈鏁忔劅淇℃伅,渚嬪鏁版嵁搴撳瘑鐮,浣犲簲璇ュ皾璇曢檺鍒惰闂畠.渚嬪,鏀瑰彉瀹冪殑鏂囦欢鏉冮檺浣垮緱鍙湁浣犲拰浣犵殑Web鏈嶅姟鍣ㄧ敤鎴峰笎鍙锋墠鑳借鍙栧畠.杩欏湪鍏变韩涓绘満鐜涓挨鍏堕噸瑕.

Creating Your Own Settings

鍒涘缓浣犺嚜宸茬殑Settings

Theres nothing stopping you from creating your own settings, for your own Django applications. Just follow these conventions:

娌℃湁浠涔堣兘澶熼樆姝綘涓鸿嚜宸卞垱寤虹殑Django搴旂敤鍒涘缓settings銆 鍙閬靛畧浠ヤ笅绾﹀畾锛

  • Use all uppercase for setting names.

  • 涓烘墍鏈夌殑閰嶇疆鍚嶄娇鐢ㄥぇ鍐欏瓧姣嶃

  • For settings that are sequences, use tuples instead of lists. Settings should be considered immutable and shouldnt be changed once theyre defined. Using tuples mirrors these semantics.

  • 瀵逛簬闆嗗悎鍨嬬殑璁剧疆锛屼娇鐢ㄥ厓缁勶紙tuple锛夛紝鑰屼笉瑕佷娇鐢ㄥ垪琛紙list锛夈傛墍鏈夌殑璁剧疆搴旇鏄簰鏂ョ殑锛屽苟涓斾竴鏃︾‘瀹氫互鍚庡氨涓嶅簲璇ュ啀鏀瑰彉銆備娇鐢ㄥ厓缁勪篃鍙嶆槧浜嗚繖鏍风殑鐞嗗康銆

  • Dont reinvent an already existing setting.

  • 涓嶈閲嶆柊鍒涘缓宸茬粡瀛樺湪鐨剆etting銆

Designating the Settings: DJANGO_SETTINGS_MODULE

鎸囨淳Settings: DJANGO_SETTINGS_MODULE

When you use Django, you have to tell it which settings youre using. Do this by using the environment variable DJANGO_SETTINGS_MODULE .

褰撲綘浣跨敤 Django 鐨勬椂鍊欙紝浣犲繀椤诲憡璇夊畠浣犵敤鐨勫摢涓 settings 锛堥厤缃級锛屼綘鍙互閫氳繃璁剧疆 DJANGO_SETTINGS_MODULE 鐜鍙橀噺鏉ュ畬鎴愩

The value of DJANGO_SETTINGS_MODULE should be in Python path syntax (e.g., mysite.settings ). Note that the settings module should be on the Python import search path (PYTHONPATH ).

DJANGO_SETTINGS_MODULE 鐨勫煎簲璇ュ湪 Python path 涓紙渚嬪锛 mysite.settings 锛夈傛敞鎰忥紝settings 妯″潡搴旇鍦≒ython import鐨勬悳绱㈣矾寰勶紙 PYTHONPATH 锛変箣涓

Tip:

鎻愮ず锛

A good guide to PYTHONPATH can be found at http://diveintopython.org/getting_to_know_python/everything_is_an_object.html.

鍏充簬 PYTHONPATH 鐨勬寚瀵兼枃妗e彲浠ュ湪 http://diveintopython.org/getting_to_know_python/everything_is_an_object.html 鎵惧埌銆

The django-admin.py Utility

django-admin.py 宸ュ叿

When using django-admin.py (see Appendix G), you can either set the environment variable once or explicitly pass in the settings module each time you run the utility.

褰撲娇鐢 django-admin.py 锛堣闄勫綍G锛夋椂锛屼綘鍙互涓娆℃ц缃幆澧冨彉閲忔垨鑰呭湪姣忔杩愯杩欎釜宸ュ叿鏃朵簬settings妯″潡涓槑纭寚鏄庛

Heres an example using the Unix Bash shell:

杩欐槸涓涓娇鐢║nix Bash Shell鐨勪緥瀛愶細

export DJANGO_SETTINGS_MODULE=mysite.settings
django-admin.py runserver

Heres an example using the Windows shell:

杩欐槸涓涓娇鐢╓indows鍛戒护琛岀殑渚嬪瓙锛

set DJANGO_SETTINGS_MODULE=mysite.settings
django-admin.py runserver

Use the --settings command-line argument to specify the settings manually:

浣跨敤 --settings 鍛戒护琛屽弬鏁版潵鎵嬪伐鎸囨槑settings锛

django-admin.py runserver --settings=mysite.settings

The manage.py utility created by startproject as part of the project skeleton sets DJANGO_SETTINGS_MODULE` automatically; see Appendix G for more about manage.py .

startproject 鍒涘缓鐨勪綔涓哄伐绋嬮鏋朵竴閮ㄥ垎鐨 manage.py 宸ュ叿浼氳嚜鍔ㄨ缃 DJANGO_SETTINGS_MODULE` 锛涘叧浜 manage.py 鐨勮缁嗚鏄庤闄勫綍G銆

On the Server (mod_python)

鏈嶅姟鍣ㄧ(mod_python)

In your live server environment, youll need to tell Apache/mod_python which settings file to use. Do that with SetEnv :

鍦ㄤ綘鐨勫疄闄呮湇鍔″櫒鐜涓紝浣犻渶瑕佸憡璇堿pache/mod_python浣跨敤鍝竴涓猻ettings鏂囦欢銆傞氳繃 SetEnv

<Location "/mysite/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</Location>

For more information, read the Django mod_python documentation online at http://www.djangoproject.com/documentation/0.96/modpython/.

瑕佷簡瑙f洿璇︾粏鐨勪俊鎭紝璇烽槄璇籇jango mod_python鍦ㄧ嚎鎵嬪唽 http://www.djangoproject.com/documentation/0.96/modpython/

Using Settings Without Setting DJANGO_SETTINGS_MODULE

涓嶈缃瓺JANGO_SETTINGS_MODULE鑰屼娇鐢⊿ettings

In some cases, you might want to bypass the DJANGO_SETTINGS_MODULE environment variable. For example, if youre using the template system by itself, you likely dont want to have to set up an environment variable pointing to a settings module.

鏈変簺鎯呭喌涓嬶紝浣犲彲鑳芥兂缁曡繃 DJANGO_SETTINGS_MODULE 鐜鍙橀噺銆備緥濡傦紝濡傛灉浣犳鍦ㄤ娇鐢ㄧ嫭绔嬬殑妯℃澘绯荤粺锛屼綘寰堝彲鑳戒笉鎯宠缃寚鍚憇ettings妯″潡鐨勭幆澧冨彉閲忋

In these cases, you can configure Djangos settings manually. Do this by calling django.conf.settings.configure() . Heres an example:

杩欏湪浜涙儏鍐典笅锛屼綘鍙互鎵嬪伐璁剧疆Django鐨剆ettings锛岄氳繃 django.conf.settings.configure() 銆傝繖閲屾湁涓涓緥瀛愶細

from django.conf import settings

settings.configure(
    DEBUG = True,
    TEMPLATE_DEBUG = True,
    TEMPLATE_DIRS = [
        '/home/web-apps/myapp',
        '/home/web-apps/base',
    ]
)

Pass configure() as many keyword arguments as youd like, with each keyword argument representing a setting and its value. Each argument name should be all uppercase, with the same name as the settings described earlier. If a particular setting is not passed to configure() and is needed at some later point, Django will use the default setting value.

Configuring Django in this fashion is mostly necessary and, indeed, recommended when youre using a piece of the framework inside a larger application.

鎸夌収姝や竴棰ㄦ牸瑷疆 Django 瀵﹀墖鏈夊叾蹇呰,灏ゅ叾鐣跺湪涓鍊嬭純澶х殑鎳夌敤绋嬪紡瑁″鐢ㄤ竴閮ㄥ垎妗嗘灦鏅.

Consequently, when configured via settings.configure() , Django will not make any modifications to the process environment variables. (See the explanation of TIME_ZONE later in this appendix for why this would normally occur.) Its assumed that youre already in full control of your environment in these cases.

Custom Default Settings

瀹氬埗榛樿鐨凷ettings

If youd like default values to come from somewhere other than django.conf.global_settings , you can pass in a module or class that provides the default settings as the default_settings argument (or as the first positional argument) in the call to configure() .

濡傛灉浣犳兂浠 django.conf.global_settings 浠ュ鐨勫湴鏂硅幏寰楅粯璁よ缃紝浣犲彲浠ヤ紶鍏ヤ竴涓彁渚涢粯璁よ缃綋浣 default_settings 鐨勫弬鏁帮紙鎴栬呭綋浣滅涓涓弬鏁) 鍒板洖璋冨嚱鏁 configure()銆

In this example, default settings are taken from myapp_defaults , and the DEBUG setting is set to True , regardless of its value in myapp_defaults :

鍦ㄤ笅闈㈢殑鍒楀瓙涓紝榛樿璁剧疆鏄槸浠巑yapp_defaults鑾峰彇鐨勶紝涓擠EBUG鏄缃负True, regardless of its value in myapp_defaults :

from django.conf import settings
from myapp import myapp_defaults

settings.configure(default_settings=myapp_defaults, DEBUG=True)

The following example, which uses myapp_defaults as a positional argument, is equivalent:

涓嬮潰鐨勪緥瀛愭槸绛変环鐨勶細

settings.configure(myapp_defaults, DEBUG = True)

Normally, you will not need to override the defaults in this fashion. The Django defaults are sufficiently tame that you can safely use them. Be aware that if you do pass in a new default module, it entirely replaces the Django defaults, so you must specify a value for every possible setting that might be used in that code you are importing. Check in django.conf.settings.global_settings for the full list.

涓鑸岃█,鎮ㄧ劇闇鏀硅畩鍏堕爯瑷. 鎮ㄦ噳瑭插彲浠ュ畨鍏ㄥ钩闋嗗湴浣跨敤 Django 鐨勯爯瑷. 瑕佹敞鎰忕殑鏄,涓鏃﹀偝閫蹭竴绲勬柊鐨勯爯瑷ā绲,鎵鏈夌殑 Django 闋愯ō璩囨枡灏囨渻鍏ㄩ儴琚*鍙栦唬*,鍥犳,蹇呴爤鍦ㄨ几鍏ョ▼寮忕⒓鏅,閲濆皪姣忎竴鍊嬪彲鑳界殑瑷畾绲﹀. 璜嬫煡闁 django.conf.settings.global_settings 浜嗚В鎵鏈夌殑鐩搁棞瑷畾.

Either configure() or DJANGO_SETTINGS_MODULE Is Required

configure()鎴朌JANGO_SETTINGS_MODULE涔嬩竴鏄繀椤荤殑

If youre not setting the DJANGO_SETTINGS_MODULE environment variable, you must call configure() at some point before using any code that reads settings.

濡傛灉浣犳病鏈夎缃甡`DJANGO_SETTINGS_MODULE``鐜鍙橀噺锛屼綘蹇呴』鍦ㄤ娇鐢ㄤ换浣曡鍙栬缃殑浠g爜涔嬪墠鐨勬煇澶勮皟鐢╜`configure()`` 鏂规硶銆

If you dont set DJANGO_SETTINGS_MODULE and dont call configure() , Django will raise an EnvironmentError exception the first time a setting is accessed.

濡傛灉浣犳病鏈夎缃甡`DJANGO_SETTINGS_MODULE`` 涔熸病鏈夎皟鐢╜`configure()``锛屽綋绗竴娆℃煇涓猻etting琚闂椂锛孌jango 灏嗕細鍑虹幇``EnvironmentError`` 寮傚父銆

If you set DJANGO_SETTINGS_MODULE , access settings values somehow, and then call configure() , Django will raise an EnvironmentError stating that settings have already been configured.

Also, its an error to call configure() more than once, or to call configure() after any setting has been accessed.

鍙﹀锛屼笉姝竴娆℃垨鍦ㄤ换浣晄etting宸茬粡琚闂箣鍚庤皟鐢╜`configure()`` 閮芥槸閿欒鐨勩

It boils down to this: use exactly one of either configure() or DJANGO_SETTINGS_MODULE . Not both, and not neither.

Available Settings

鍙敤鐨勮ō瀹

The following sections consist of a full list of all available settings, in alphabetical order, and their default values.

涓嬮潰绔犺妭鍖呮嫭鍏ㄩ儴鏈夋晥setting椤癸紙鎸夊瓧姣嶉『搴忔帓搴忥級鍙婂叾榛樿鍊肩殑涓涓畬鏁村垪琛ㄣ

ABSOLUTE_URL_OVERRIDES

ABSOLUTE_URL_OVERRIDES

Default : {} (empty dictionary)

榛樿 : {} (empty dictionary)

This is a dictionary mapping "app_label.model_name" strings to functions that take a model object and return its URL. This is a way of overriding get_absolute_url() methods on a per-installation basis. Heres an example:

000000000000000000000000000000

ABSOLUTE_URL_OVERRIDES = {
    'blogs.weblog': lambda o: "/blogs/%s/" % o.slug,
    'news.story': lambda o: "/stories/%s/%s/" % (o.pub_year, o.slug),
}

Note that the model name used in this setting should be all lowercase, regardless of the case of the actual model class name.

ADMIN_FOR

ADMIN_FOR

Default : () (empty list)

榛樿 : () (empty list)

This setting is used for admin site settings modules. It should be a tuple of settings modules (in the format 'foo.bar.baz' ) for which this site is an admin.

The admin site uses this in its automatically introspected documentation of models, views, and template tags.

ADMIN_MEDIA_PREFIX

ADMIN_MEDIA_PREFIX

Default : '/media/'

榛樿 : '/media/'

This setting is the URL prefix for admin media: CSS, JavaScript, and images. Make sure to use a trailing slash.

姝よ缃槸鐢ㄦ潵璁剧疆绠$悊妯″紡鐨勯潤鎬佹枃浠讹紙鍖呮嫭CSS锛孞avaScript鍜屽浘鍍忥級URL鐨勫墠缂銆傛敞鎰忚浣跨敤鏂滅嚎

ADMINS

ADMINS

Default : () (empty tuple)

榛樿 : () (empty tuple)

This is a tuple that lists people who get code error notifications. When DEBUG=False and a view raises an exception, Django will email these people with the full exception information. Each member of the tuple should be a tuple of (Full name, e-mail address), for example:

(('John', 'john@example.com'), ('Mary', 'mary@example.com'))

Note that Django will email all of these people whenever an error happens.

姣忓綋涓涓敊璇鎹曡幏鐨勬椂鍊欙紝Django 灏嗗彂閫佺粰鎵鏈夎繖浜涗汉

ALLOWED_INCLUDE_ROOTS

ALLOWED_INCLUDE_ROOTS

Default : () (empty tuple)

榛樿 : () (empty tuple)

This is a tuple of strings representing allowed prefixes for the {% ssi %} template tag. This is a security measure, so that template authors cant access files that they shouldnt be accessing.

For example, if ALLOWED_INCLUDE_ROOTS is ('/home/html', '/var/www') , then {% ssi /home/html/foo.txt %} would work, but {% ssi /etc/passwd %} wouldnt.

APPEND_SLASH

APPEND_SLASH

Default : True

榛樿 : True

This setting indicates whether to append trailing slashes to URLs. This is used only if CommonMiddleware is installed (see Chapter 15). See also PREPEND_WWW .

褰撴璁剧疆椤逛负True鐨勬椂鍊欙紝绯荤粺浼氳嚜鍔ㄥ湪URL鐨勫熬閮ㄥ姞涓婁竴涓弽鏂滄潬’/’銆傝繖涓缃」浠呬粎鍦ㄥ畨瑁呬簡``CommonMiddleware``鐨勭姸鎬佷笅浣跨敤锛堣瑙佺15绔狅級鐨刞`PREPEND_WWW``

CACHE_BACKEND

CACHE_BACKEND

Default : 'simple://'

榛樿 : 'simple://'

This is the cache back-end to use (see Chapter 13).

鎸囧畾浣跨敤鐨勭紦瀛樺悗绔紙瑙佺 13 绔狅級銆

CACHE_MIDDLEWARE_KEY_PREFIX

CACHE_MIDDLEWARE_KEY_PREFIX

Default : '' (empty string)

榛樿 : '' (empty string)

This is the cache key prefix that the cache middleware should use (see Chapter 13).

DATABASE_ENGINE

DATABASE_ENGINE

Default : '' (empty string)

榛樿 : '' (empty string)

This setting indicates which database back-end to use: 'postgresql_psycopg2' , 'postgresql' , 'mysql' , 'mysql_old' or 'sqlite3' .

璇ヨ缃敤浜庢寚瀹氫娇鐢ㄤ笅鍒楀摢绉嶆暟鎹簱浣滀负瀛樺偍鍚庣: 'postgresql_psycopg2' , 'postgresql' , 'mysql' , 'mysql_old' or 'sqlite3' .

DATABASE_HOST

DATABASE_HOST

Default : '' (empty string)

榛樿 : '' (empty string)

This setting indicates which host to use when connecting to the database. An empty string means localhost . This is not used with SQLite.

璇ヨ缃寚瀹氳繛鎺ユ暟鎹簱鏃舵墍浣跨敤鐨勪富鏈恒傜┖瀛楃涓茶〃绀篳`localhost`` 銆傚鏋滀綘浣跨敤SQLite锛屽垯涓嶇敤璁剧疆璇ュ笺

If this value starts with a forward slash ('/' ) and youre using MySQL, MySQL will connect via a Unix socket to the specified socket:

濡傛灉浣犲湪浣跨敤MySQL锛岃岃繖涓兼槸浠ュ弽鏂滅嚎('/' )寮澶达紝閭d箞MySQL灏嗛氳繃鎸囧畾鐨刄nix socket杩涜杩炴帴锛

DATABASE_HOST = '/var/run/mysql'

If youre using MySQL and this value doesnt start with a forward slash, then this value is assumed to be the host.

濡傛灉浣犲湪浣跨敤MySQL锛岃岃繖涓煎張娌℃湁浠ュ弽鏂滅嚎寮澶达紝閭d箞杩欎釜鍊煎氨琚涓烘槸涓绘満銆

DATABASE_NAME

DATABASE_NAME

Default : '' (empty string)

榛樿 : '' (empty string)

This is the name of the database to use. For SQLite, its the full path to the database file.

璇ヨ缃负鎵浣跨敤鏁版嵁搴撶殑鍚嶇О銆傚鏋滀娇鐢⊿QLite锛岃璁剧疆涓烘暟鎹簱鏂囦欢鐨勫畬鏁磋矾寰勩

DATABASE_OPTIONS

DATABASE_OPTIONS

Default : {} (empty dictionary)

榛樿 : {} (empty dictionary)

This is extra parameters to use when connecting to the database. Consult the back-end modules document for available keywords.

DATABASE_PASSWORD

DATABASE_PASSWORD

Default : '' (empty string)

榛樿 : '' (empty string)

This setting is the password to use when connecting to the database. It is not used with SQLite.

璇ヨ缃负鏁版嵁搴撹繛鎺ュ瘑鐮併傚鏋滀娇鐢⊿QLite锛屽垯涓嶇敤璁剧疆銆

DATABASE_PORT

DATABASE_PORT

Default : '' (empty string)

榛樿 : '' (empty string)

This is the port to use when connecting to the database. An empty string means the default port. It is not used with SQLite.

杩欐槸鐢ㄦ潵杩炴帴鏁版嵁搴撶殑绔彛. 绌哄瓧绗︿唬琛ㄧ己鐪佺鍙. SQLite 涓嶇敤璁剧疆.

DATABASE_USER

DATABASE_USER

Default : '' (empty string)

榛樿 : '' (empty string)

This setting is the username to use when connecting to the database. It is not used with SQLite.

璇ヨ缃负杩炴帴鏁版嵁搴撶殑鐢ㄦ埛鍚嶃傚綋浣跨敤 SQLite 鏃舵棤鏁堛

DATE_FORMAT

DATE_FORMAT

Default : 'N j, Y' (e.g., Feb. 4, 2003 )

榛樿 : 'N j, Y' (e.g., Feb. 4, 2003 )

This is the default formatting to use for date fields on Django admin change-list pages and, possibly, by other parts of the system. It accepts the same format as the now tag (see Appendix F, Table F-2).

See also DATETIME_FORMAT , TIME_FORMAT , YEAR_MONTH_FORMAT , and MONTH_DAY_FORMAT .

鍙﹁ DATETIME_FORMAT , TIME_FORMAT , YEAR_MONTH_FORMAT , 鍜 MONTH_DAY_FORMAT .

DATETIME_FORMAT

DATETIME_FORMAT

Default : 'N j, Y, P' (e.g., Feb. 4, 2003, 4 p.m. )

榛樿 : 'N j, Y, P' (渚嬪, Feb. 4, 2003, 4 p.m. )

This is the default formatting to use for datetime fields on Django admin change-list pages and, possibly, by other parts of the system. It accepts the same format as the now tag (see Appendix F, Table F-2).

See also DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , YEAR_MONTH_FORMAT , and MONTH_DAY_FORMAT .

鍙﹁ DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , YEAR_MONTH_FORMAT , 鍜 MONTH_DAY_FORMAT .

DEBUG

DEBUG

Default : False

榛樿 : False

This setting is a Boolean that turns debug mode on and off.

杩欎釜璁剧疆椤规槸涓涓爣绀篸ebug寮鍏崇殑甯冨皵鍊笺

If you define custom settings, django/views/debug.py has a HIDDEN_SETTINGS regular expression that will hide from the DEBUG view anything that contains 'SECRET , PASSWORD , or PROFANITIES' . This allows untrusted users to be able to give backtraces without seeing sensitive (or offensive) settings.

Still, note that there are always going to be sections of your debug output that are inappropriate for public consumption. File paths, configuration options, and the like all give attackers extra information about your server. Never deploy a site with DEBUG turned on.

DEFAULT_CHARSET

DEFAULT_CHARSET

Default : 'utf-8'

榛樿 : 'utf-8'

This is the default charset to use for all HttpResponse objects, if a MIME type isnt manually specified. It is used with DEFAULT_CONTENT_TYPE to construct the Content-Type header. See Appendix H for more about HttpResponse objects.

DEFAULT_CONTENT_TYPE

DEFAULT_CONTENT_TYPE

Default : 'text/html'

榛樿 : 'text/html'

This is the default content type to use for all HttpResponse objects, if a MIME type isnt manually specified. It is used with DEFAULT_CHARSET to construct the Content-Type header. See Appendix H for more about HttpResponse objects.

DEFAULT_FROM_EMAIL

DEFAULT_FROM_EMAIL

Default : 'webmaster@localhost'

榛樿 : 'webmaster@localhost'

This is the default email address to use for various automated correspondence from the site manager(s).

DISALLOWED_USER_AGENTS

DISALLOWED_USER_AGENTS

Default : () (empty tuple)

榛樿 : () (empty tuple)

This is a list of compiled regular expression objects representing User-Agent strings that are not allowed to visit any page, systemwide. Use this for bad robots/crawlers. This is used only if CommonMiddleware is installed (see Chapter 15).

EMAIL_HOST

EMAIL_HOST

Default : 'localhost'

榛樿 : 'localhost'

This is the host to use for sending email. See also EMAIL_PORT .

EMAIL_HOST_PASSWORD

EMAIL_HOST_PASSWORD

Default : '' (empty string)

榛樿 : '' (empty string)

This is the password to use for the SMTP server defined in EMAIL_HOST . This setting is used in conjunction with EMAIL_HOST_USER when authenticating to the SMTP server. If either of these settings is empty, Django wont attempt authentication.

See also EMAIL_HOST_USER .

鍙﹁ EMAIL_HOST_USER .

EMAIL_HOST_USER

EMAIL_HOST_USER

Default : '' (empty string)

榛樿 : '' (empty string)

This is the username to use for the SMTP server defined in EMAIL_HOST . If its empty, Django wont attempt authentication. See also EMAIL_HOST_PASSWORD .

EMAIL_PORT

EMAIL_PORT

Default : 25

榛樿 : 25

This is the port to use for the SMTP server defined in EMAIL_HOST .

EMAIL_SUBJECT_PREFIX

EMAIL_SUBJECT_PREFIX

Default : '[Django] '

榛樿 : '[Django] '

This is the subject-line prefix for email messages sent with django.core.mail.mail_admins or django.core.mail.mail_managers . Youll probably want to include the trailing space.

FIXTURE_DIRS

FIXTURE_DIRS

Default : () (empty tuple)

榛樿 : () (empty tuple)

This is a list of locations of the fixture data files, in search order. Note that these paths should use Unix-style forward slashes, even on Windows. It is used by Djangos testing framework, which is covered online at http://www.djangoproject.com/documentation/0.96/testing/.

IGNORABLE_404_ENDS

IGNORABLE_404_ENDS

Default : ('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico', '.php')

榛樿 : ('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico', '.php')

See also IGNORABLE_404_STARTS and Error reporting via e-mail .

鍙﹁ IGNORABLE_404_STARTSError reporting via e-mail .

IGNORABLE_404_STARTS

IGNORABLE_404_STARTS

Default : ('/cgi-bin/', '/_vti_bin', '/_vti_inf')

榛樿 : ('/cgi-bin/', '/_vti_bin', '/_vti_inf')

This is a tuple of strings that specify beginnings of URLs that should be ignored by the 404 emailer. See also SEND_BROKEN_LINK_EMAILS and IGNORABLE_404_ENDS .

INSTALLED_APPS

INSTALLED_APPS

Default : () (empty tuple)

榛樿 : () (empty tuple)

A tuple of strings designating all applications that are enabled in this Django installation. Each string should be a full Python path to a Python package that contains a Django application. See Chapter 5 for more about applications.

INTERNAL_IPS

INTERNAL_IPS

Default : () (empty tuple)

榛樿 : () (empty tuple)

A tuple of IP addresses, as strings, that

  • See debug comments, when DEBUG is True

  • Receive X headers if the XViewMiddleware is installed (see Chapter 15)

JING_PATH

JING_PATH

Default : '/usr/bin/jing'

榛樿 : '/usr/bin/jing'

This is the path to the Jing executable. Jing is a RELAX NG validator, and Django uses it to validate each XMLField in your models. See http://www.thaiopensource.com/relaxng/jing.html.

LANGUAGE_CODE

LANGUAGE_CODE

Default : 'en-us'

榛樿 : 'en-us'

This is a string representing the language code for this installation. This should be in standard language format for example, U.S. English is "en-us" . See Chapter 18.

LANGUAGES

LANGUAGES

Default : A tuple of all available languages. This list is continually growing and any copy included here would inevitably become rapidly out of date. You can see the current list of translated languages by looking in django/conf/global_settings.py .

The list is a tuple of two-tuples in the format (language code, language name) for example, ('ja', 'Japanese') . This specifies which languages are available for language selection. See Chapter 18 for more on language selection.

Generally, the default value should suffice. Only set this setting if you want to restrict language selection to a subset of the Django-provided languages.

If you define a custom LANGUAGES setting, its OK to mark the languages as translation strings, but you should never import django.utils.translation from within your settings file, because that module in itself depends on the settings, and that would cause a circular import.

The solution is to use a dummy gettext() function. Heres a sample settings file:

gettext = lambda s: s

LANGUAGES = (
    ('de', gettext('German')),
    ('en', gettext('English')),
)

With this arrangement, make-messages.py will still find and mark these strings for translation, but the translation wont happen at runtime so youll have to remember to wrap the languages in the real gettext() in any code that uses LANGUAGES at runtime.

MANAGERS

MANAGERS

Default : () (empty tuple)

榛樿 : () (empty tuple)

This tuple is in the same format as ADMINS that specifies who should get broken-link notifications when SEND_BROKEN_LINK_EMAILS=True .

MEDIA_ROOT

MEDIA_ROOT

Default : '' (empty string)

榛樿 : '' (empty string)

This is an absolute path to the directory that holds media for this installation (e.g., "/home/media/media.lawrence.com/" ). See also MEDIA_URL .

MEDIA_URL

MEDIA_URL

Default : '' (empty string)

榛樿 : '' (empty string)

This URL handles the media served from MEDIA_ROOT (e.g., "http://media.lawrence.com" ).

Note that this should have a trailing slash if it has a path component:

  • Correct : "http://www.example.com/static/"

  • 姝g‘ : "http://www.example.com/static/"

  • Incorrect : "http://www.example.com/static"

  • 閿欒 : "http://www.example.com/static"

MIDDLEWARE_CLASSES

MIDDLEWARE_CLASSES

Default :

榛樿 :

("django.contrib.sessions.middleware.SessionMiddleware",
 "django.contrib.auth.middleware.AuthenticationMiddleware",
 "django.middleware.common.CommonMiddleware",
 "django.middleware.doc.XViewMiddleware")

This is a tuple of middleware classes to use. See Chapter 15.

MONTH_DAY_FORMAT

MONTH_DAY_FORMAT

Default : 'F j'

榛樿 : 'F j'

This is the default formatting to use for date fields on Django admin change-list pages and, possibly, by other parts of the system in cases when only the month and day are displayed. It accepts the same format as the now tag (see Appendix F, Table F-2).

For example, when a Django admin change-list page is being filtered by a date, the header for a given day displays the day and month. Different locales have different formats. For example, U.S. English would have January 1, whereas Spanish might have 1 Enero.

See also DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , and YEAR_MONTH_FORMAT .

鍙﹁ DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , 鍜 YEAR_MONTH_FORMAT .

PREPEND_WWW

PREPEND_WWW

Default : False

榛樿 : False

This setting indicates whether to prepend the www. subdomain to URLs that dont have it. This is used only if CommonMiddleware is installed (see the Chapter 15). See also APPEND_SLASH .

PROFANITIES_LIST

PROFANITIES_LIST

This is a tuple of profanities, as strings, that will trigger a validation error when the hasNoProfanities validator is called.

We dont list the default values here, because that might bring the MPAA ratings board down on our heads. To view the default values, see the file django/conf/global_settings.py .

ROOT_URLCONF

ROOT_URLCONF

Default : Not defined

榛樿 : Not defined

This is a string representing the full Python import path to your root URLconf (e.g., "mydjangoapps.urls" ). See Chapter 3.

SECRET_KEY

SECRET_KEY

Default : (Generated automatically when you start a project)

榛樿 : (褰撲綘鍒涘缓涓涓」鐩椂鑷姩鐢熸垚)

This is a secret key for this particular Django installation. It is used to provide a seed in secret-key hashing algorithms. Set this to a random string the longer, the better. django-admin.py startproject creates one automatically and most of the time you wont need to change it

SEND_BROKEN_LINK_EMAILS

Default : False

榛樿 : False

This setting indicates whether to send an email to the MANAGERS each time somebody visits a Django-powered page that is 404-ed with a nonempty referer (i.e., a broken link). This is only used if CommonMiddleware is installed (see Chapter 15). See also IGNORABLE_404_STARTS and IGNORABLE_404_ENDS .

SERIALIZATION_MODULES

SERIALIZATION_MODULES

Default : Not defined.

榛樿 : Not defined.

Serialization is a feature still under heavy development. Refer to the online documentation at http://www.djangoproject.com/documentation/0.96/serialization/ for more information.

SERVER_EMAIL

SERVER_EMAIL

Default : 'root@localhost'

榛樿 : 'root@localhost'

This is the email address that error messages come from, such as those sent to ADMINS and MANAGERS .

SESSION_COOKIE_AGE

Default : 1209600 (two weeks, in seconds)

榛樿 : 1209600 (涓ゅ懆锛屼互绉掕)

This is the age of session cookies, in seconds. See Chapter 12.

SESSION_COOKIE_DOMAIN

Default : None

榛樿 : None

This is the domain to use for session cookies. Set this to a string such as ".lawrence.com" for cross-domain cookies, or use None for a standard domain cookie. See Chapter 12.

SESSION_COOKIE_NAME

Default : 'sessionid'

榛樿 : 'sessionid'

This is the name of the cookie to use for sessions; it can be whatever you want. See Chapter 12.

SESSION_COOKIE_SECURE

Default : False

榛樿 : False

This setting indicates whether to use a secure cookie for the session cookie. If this is set to True , the cookie will be marked as secure, which means browsers may ensure that the cookie is only sent under an HTTPS connection. See Chapter 12.

SESSION_EXPIRE_AT_BROWSER_CLOSE

SESSION_EXPIRE_AT_BROWSER_CLOSE

Default : False

榛樿 : False

This setting indicates whether to expire the session when the user closes his browser. See Chapter 12.

SESSION_SAVE_EVERY_REQUEST

SESSION_SAVE_EVERY_REQUEST

Default : False

榛樿 : False

This setting indicates whether to save the session data on every request. See Chapter 12.

SITE_ID

SITE_ID

Default : Not defined

榛樿 : Not defined

This is the ID, as an integer, of the current site in the django_site database table. It is used so that application data can hook into specific site(s) and a single database can manage content for multiple sites. See Chapter 14.

杩欏氨鏄湪鈥渄jango_site鈥濇暟鎹簱琛ㄤ腑褰撳墠缃戠珯鐨勬暣鏁癐D銆傚畠甯哥敤浜庡簲鐢ㄧ▼搴忔暟鎹兘澶熸寕閽╁埌鎸囧畾鐨勭綉绔欙紝鎴栧崟涓暟鎹簱涓婅兘绠$悊澶氫釜缃戠珯鐨勫唴瀹广傚弬瑙佺14绔犮

TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS

Default :

榛樿 :

("django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n")

This is a tuple of callables that are used to populate the context in RequestContext . These callables take a request object as their argument and return a dictionary of items to be merged into the context. See Chapter 10.

TEMPLATE_DEBUG

TEMPLATE_DEBUG

Default : False

榛樿 : False

This Boolean turns template debug mode on and off. If it is True , the fancy error page will display a detailed report for any TemplateSyntaxError . This report contains the relevant snippet of the template, with the appropriate line highlighted.

Note that Django only displays fancy error pages if DEBUG is True , so youll want to set that to take advantage of this setting.

See also DEBUG .

鍙﹁ DEBUG .

TEMPLATE_DIRS

TEMPLATE_DIRS

Default : () (empty tuple)

榛樿 : () (empty tuple)

This is a list of locations of the template source files, in search order. Note that these paths should use Unix-style forward slashes, even on Windows. See Chapters 4 and 10.

杩欐槸涓涓牴鎹悳绱㈡帓搴忕殑妯℃澘婧愭枃浠剁殑浣嶇疆鍒楄〃銆傛敞鎰忥紝杩欎簺璺緞搴旇浣跨敤Unix椋庢牸鐨勫垎鍓茬锛屽嵆浣垮湪Windows涓娿傚弬鍔犵4鍜10绔犮

TEMPLATE_LOADERS

TEMPLATE_LOADERS

Default : ('django.template.loaders.filesystem.load_template_source',)

榛樿 : ('django.template.loaders.filesystem.load_template_source',)

This is a tuple of callables (as strings) that know how to import templates from various sources. See Chapter 10.

TEMPLATE_STRING_IF_INVALID

TEMPLATE_STRING_IF_INVALID

Default : '' (Empty string)

榛樿 : '' (Empty string)

This is output, as a string, that the template system should use for invalid (e.g., misspelled) variables. See Chapter 10.

TEST_RUNNER

TEST_RUNNER

Default : 'django.test.simple.run_tests'

榛樿 : 'django.test.simple.run_tests'

This is the name of the method to use for starting the test suite. It is used by Djangos testing framework, which is covered online at http://www.djangoproject.com/documentation/0.96/testing/.

杩欐槸鐢ㄤ簬鍚姩娴嬭瘯濂椾欢鐨勬柟娉曞悕绉般傚畠鐢ㄥ湪Django娴嬭瘯妗嗘灦涓紝鍙傝http://www.djangoproject.com/documentation/0.96/testing 銆

TEST_DATABASE_NAME

TEST_DATABASE_NAME

Default : None

榛樿 : None

This is the name of database to use when running the test suite. If a value of None is specified, the test database will use the name 'test_' + settings.DATABASE_NAME . See the documentation for Djangos testing framework, which is covered online at http://www.djangoproject.com/documentation/0.96/testing/.

杩欐槸鐢ㄤ簬鎵ц娴嬭瘯濂椾欢鐨勬暟鎹悕绉般傚鏋滆鍊间负None, 閭d箞娴嬭瘯鏁版嵁搴撳皢浼氫娇鐢ㄥ悕绉’test_‘ + settings.DATABASE_NAME銆傚弬瑙丏jango娴嬭瘯妗嗘灦鐨勬枃妗o紝浣嶄簬http://www.djangoproject.com/documentation/0.96/testing/ 銆

TIME_FORMAT

TIME_FORMAT

Default : 'P' (e.g., 4 p.m. )

榛樿 : 'P' (e.g., 4 p.m. )

This is the default formatting to use for time fields on Django admin change-list pages and, possibly, by other parts of the system. It accepts the same format as the now tag (see Appendix F, Table F-2).

See also DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , YEAR_MONTH_FORMAT , and MONTH_DAY_FORMAT .

鍙﹁ DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , YEAR_MONTH_FORMAT , 鍜 MONTH_DAY_FORMAT .

TIME_ZONE

TIME_ZONE

Default : 'America/Chicago'

榛樿 : 'America/Chicago'

This is a string representing the time zone for this installation. Time zones are in the Unix-standard zic format. One relatively complete list of time zone strings can be found at http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE.

姝ゅ瓧绗︿覆琛ㄧず瀹夎鐨勬椂鍖恒傛椂鍖轰负Unix鏍囧噯鐨剒ic鏍煎紡銆傚湪http://www.postgresql.org/docs/8.1/static/dateime-keywords.html#DATETIME-TIMEZONE-SET-TABLE涓婃湁涓涓浉瀵瑰畬鏁寸殑鏃跺尯瀛楃涓插垪琛ㄣ

This is the time zone to which Django will convert all dates/times not necessarily the time zone of the server. For example, one server may serve multiple Django-powered sites, each with a separate time-zone setting.

杩欐槸Django杞崲鍖呮嫭鏈嶅姟鍣ㄦ椂鍖哄湪鍐呯殑鎵鏈夋棩鏈燂紡鏃堕棿鏃舵墍鐢ㄧ殑鏃跺尯銆備緥濡傦紝涓涓湇鍔″櫒鍙互鎵樼澶氫釜Django绔欑偣锛屾瘡涓珯鐐规湁涓涓嫭绔嬬殑鏃跺尯璁剧疆銆

Normally, Django sets the os.environ['TZ'] variable to the time zone you specify in the TIME_ZONE setting. Thus, all your views and models will automatically operate in the correct time zone. However, if youre using the manually configuring settings (described above in the section titled Using Settings Without Setting DJANGO_SETTINGS_MODULE), Django will not touch the TZ environment variable, and it will be up to you to ensure your processes are running in the correct environment.

Note

娉ㄦ剰

Django cannot reliably use alternate time zones in a Windows environment. If youre running Django on Windows, this variable must be set to match the system time zone.

Django涓嶈兘鍙潬鍦颁娇鐢╓indows鐜閲岀殑鍙夋椂鍖恒傚鏋滀綘鍦╓indows涓婅繍琛孌jango锛岃繖涓彉閲忓繀椤昏缃负涓庣郴缁熸椂鍖轰竴鑷淬

URL_VALIDATOR_USER_AGENT

URL_VALIDATOR_USER_AGENT

Default : Django/<version> (http://www.djangoproject.com/)

榛樿 : Django/<version> (http://www.djangoproject.com/)

This is the string to use as the User-Agent header when checking to see if URLs exist (see the verify_exists option on URLField ; see Appendix B).

杩欐槸褰撴鏌rl鏄惁瀛樺湪鏃剁敤浜庘淯ser-Agent鈥濈殑瀛楃涓诧紙 鍙傝鈥淯RLField鈥濈殑鈥渧erify_exists鈥濋夐」锛涘弬瑙侀檮褰旴锛夈

USE_ETAGS

USE_ETAGS

Default : False

榛樿 : False

This Boolean specifies whether to output the ETag header. It saves bandwidth but slows down performance. This is only used if CommonMiddleware is installed (see Chapter 15).

姝ら昏緫鍊兼寚瀹氭槸鍚﹁緭鍑篍Tag鍓嶇紑銆傝繖浼氳妭鐪佸甫瀹戒絾鏄檷浣庢ц兘銆備竴鑸彧鏈夊綋瀹夎浜嗘椂鎵嶄娇鐢ㄦ閫夐」锛堝弬瑙佺15绔狅級銆

USE_I18N

USE_I18N

Default : True

榛樿 : True

This Boolean specifies whether Djangos internationalization system (see Chapter 18) should be enabled. It provides an easy way to turn off internationalization, for performance. If this is set to False , Django will make some optimizations so as not to load the internationalization machinery.

姝ら昏緫鍊兼寚瀹欴jango鍥介檯鍖栫郴缁燂紙鍙傝绗18绔狅級鏄惁鍙敤銆傝繖鎻愪緵浜嗕竴涓洜涓烘ц兘鑰屽叧闂浗闄呭寲鐨勭畝鍗曟柟娉曘傚鏋滄鍊艰涓衡淔alse鈥,Django灏嗕細鍋氫竴浜涗紭鍖栦互鏇夸唬鏈姞杞界殑鍥介檯鍖栨満鍒躲

YEAR_MONTH_FORMAT

YEAR_MONTH_FORMAT

Default : 'F Y'

榛樿 : 'F Y'

This is the default formatting to use for date fields on Django admin change-list pages and, possibly, by other parts of the system in cases when only the year and month are displayed. It accepts the same format as the now tag (see Appendix F).

杩欐槸榛樿鏍煎紡锛岀敤浜嶥jango绠$悊鍙樻洿鍒楄〃椤甸潰鐨勬棩鏈熷煙锛屽苟涓旀湁鍙兘锛屼篃鐢ㄤ簬绯荤粺鍏朵粬閮ㄥ垎鐨勫彧鏄剧ず骞存湀鐨勬儏鍐点傗渘ow鈥濇爣绛炬帴鍙楃浉鍚岀殑鏍煎紡銆傦紙鍙傝闄勫綍F锛夈

For example, when a Django admin change-list page is being filtered by a date drill-down, the header for a given month displays the month and the year. Different locales have different formats. For example, U.S. English would use January 2006, whereas another locale might use 2006/January.

渚嬪锛屽綋涓涓狣jango绠$悊鍙樻洿鍒楄〃涔熻涓涓棩鏈熻繃婊ゆ椂锛岀粰鍑虹殑鏈堜唤鍓嶇紑浼氭樉绀哄嚭骞存湀銆備笉鍚岀殑鍦板尯鏈変笉鍚岀殑鏍煎紡锛屾瘮濡傜編鍥借嫳璇細浣跨敤January 2006锛岃屽叾浠栧湴鍖哄彲鑳戒娇鐢2006/January銆

See also DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , and MONTH_DAY_FORMAT .

鍙﹁ DATE_FORMAT , DATETIME_FORMAT , TIME_FORMAT , 鍜 MONTH_DAY_FORMAT .

Docutils System Messages

System Message: ERROR/3 (<string>, line 3119); backlink

Unknown target name: “test”.

Copyright 2006 Adrian Holovaty and Jacob Kaplan-Moss.
This work is licensed under the GNU Free Document License.
Hosting graciously provided by media temple
Chinese translate hosting by py3k.cn.