Django基于Pycharm开发之三[LANGUAGE_CODE与TIME_ZONE]
在django/conf/global_settings.py 中,我们可以找到关于language和timezone的通用配置信息,源码如下:
| # Local time zone for this installation. All choices can be found here: |
| # https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all | |
| # systems may support all possibilities). When USE_TZ is True, this is | |
| # interpreted as the default user time zone. | |
| TIME_ZONE = 'America/Chicago' | |
| # If you set this to True, Django will use timezone-aware datetimes. | |
| USE_TZ = False | |
| # Language code for this installation. All choices can be found here: | |
| # http://www.i18nguy.com/unicode/language-identifiers.html | |
| LANGUAGE_CODE = 'en-us' | |
| # Languages we provide translations for, out of the box. | |
| LANGUAGES = [ | |
| ('af', gettext_noop('Afrikaans')), | |
| ('ar', gettext_noop('Arabic')), | |
| ('ast', gettext_noop('Asturian')), | |
| ('az', gettext_noop('Azerbaijani')), | |
| ('bg', gettext_noop('Bulgarian')), | |
| ('be', gettext_noop('Belarusian')), | |
| ('bn', gettext_noop('Bengali')), | |
| ('br', gettext_noop('Breton')), | |
| ('bs', gettext_noop('Bosnian')), | |
| ('ca', gettext_noop('Catalan')), | |
| ('cs', gettext_noop('Czech')), | |
| ('cy', gettext_noop('Welsh')), | |
| ('da', gettext_noop('Danish')), | |
| ('de', gettext_noop('German')), | |
| ('dsb', gettext_noop('Lower Sorbian')), | |
| ('el', gettext_noop('Greek')), | |
| ('en', gettext_noop('English')), | |
| ('en-au', gettext_noop('Australian English')), | |
| ('en-gb', gettext_noop('British English')), | |
| ('eo', gettext_noop('Esperanto')), | |
| ('es', gettext_noop('Spanish')), | |
| ('es-ar', gettext_noop('Argentinian Spanish')), | |
| ('es-co', gettext_noop('Colombian Spanish')), | |
| ('es-mx', gettext_noop('Mexican Spanish')), | |
| ('es-ni', gettext_noop('Nicaraguan Spanish')), | |
| ('es-ve', gettext_noop('Venezuelan Spanish')), | |
| ('et', gettext_noop('Estonian')), | |
| ('eu', gettext_noop('Basque')), | |
| ('fa', gettext_noop('Persian')), | |
| ('fi', gettext_noop('Finnish')), | |
| ('fr', gettext_noop('French')), | |
| ('fy', gettext_noop('Frisian')), | |
| ('ga', gettext_noop('Irish')), | |
| ('gd', gettext_noop('Scottish Gaelic')), | |
| ('gl', gettext_noop('Galician')), | |
| ('he', gettext_noop('Hebrew')), | |
| ('hi', gettext_noop('Hindi')), | |
| ('hr', gettext_noop('Croatian')), | |
| ('hsb', gettext_noop('Upper Sorbian')), | |
| ('hu', gettext_noop('Hungarian')), | |
| ('ia', gettext_noop('Interlingua')), | |
| ('id', gettext_noop('Indonesian')), | |
| ('io', gettext_noop('Ido')), | |
| ('is', gettext_noop('Icelandic')), | |
| ('it', gettext_noop('Italian')), | |
| ('ja', gettext_noop('Japanese')), | |
| ('ka', gettext_noop('Georgian')), | |
| ('kab', gettext_noop('Kabyle')), | |
| ('kk', gettext_noop('Kazakh')), | |
| ('km', gettext_noop('Khmer')), | |
| ('kn', gettext_noop('Kannada')), | |
| ('ko', gettext_noop('Korean')), | |
| ('lb', gettext_noop('Luxembourgish')), | |
| ('lt', gettext_noop('Lithuanian')), | |
| ('lv', gettext_noop('Latvian')), | |
| ('mk', gettext_noop('Macedonian')), | |
| ('ml', gettext_noop('Malayalam')), | |
| ('mn', gettext_noop('Mongolian')), | |
| ('mr', gettext_noop('Marathi')), | |
| ('my', gettext_noop('Burmese')), | |
| ('nb', gettext_noop('Norwegian Bokmål')), | |
| ('ne', gettext_noop('Nepali')), | |
| ('nl', gettext_noop('Dutch')), | |
| ('nn', gettext_noop('Norwegian Nynorsk')), | |
| ('os', gettext_noop('Ossetic')), | |
| ('pa', gettext_noop('Punjabi')), | |
| ('pl', gettext_noop('Polish')), | |
| ('pt', gettext_noop('Portuguese')), | |
| ('pt-br', gettext_noop('Brazilian Portuguese')), | |
| ('ro', gettext_noop('Romanian')), | |
| ('ru', gettext_noop('Russian')), | |
| ('sk', gettext_noop('Slovak')), | |
| ('sl', gettext_noop('Slovenian')), | |
| ('sq', gettext_noop('Albanian')), | |
| ('sr', gettext_noop('Serbian')), | |
| ('sr-latn', gettext_noop('Serbian Latin')), | |
| ('sv', gettext_noop('Swedish')), | |
| ('sw', gettext_noop('Swahili')), | |
| ('ta', gettext_noop('Tamil')), | |
| ('te', gettext_noop('Telugu')), | |
| ('th', gettext_noop('Thai')), | |
| ('tr', gettext_noop('Turkish')), | |
| ('tt', gettext_noop('Tatar')), | |
| ('udm', gettext_noop('Udmurt')), | |
| ('uk', gettext_noop('Ukrainian')), | |
| ('ur', gettext_noop('Urdu')), | |
| ('vi', gettext_noop('Vietnamese')), | |
| ('zh-hans', gettext_noop('Simplified Chinese')), | |
| ('zh-hant', gettext_noop('Traditional Chinese')), | |
| ] |
在这里,我们可以找到关于language_code的缩写,对应的关于time_zone,我们可以在这里找到相关信息
#something you want can find by https://github.com/django/django/blob/master/django/conf/global_settings.py
# Local time zone for this installation. All choices can be found here:
# https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all
# systems may support all possibilities). When USE_TZ is True, this is
# interpreted as the default user time zone.
TIME_ZONE
Default: 'America/Chicago'
A string representing the time zone for this installation. See the list of time zones.
Note
Since Django was first released with the TIME_ZONE set to 'America/Chicago', the global setting (used if nothing is defined in your project’s settings.py) remains 'America/Chicago' for backwards compatibility. New project templates default to 'UTC'.
Note that this isn’t necessarily the time zone of the server. For example, one server may serve multiple Django-powered sites, each with a separate time zone setting.
When USE_TZ is False, this is the time zone in which Django will store all datetimes. When USE_TZ is True, this is the default time zone that Django will use to display datetimes in templates and to interpret datetimes entered in forms.
On Unix environments (where time.tzset() is implemented), 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 this time zone. However, Django won’t set the TZ environment variable if you’re using the manual configuration option as described in manually configuring settings. If Django doesn’t set the TZ environment variable, it’s 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 you’re running Django on Windows, TIME_ZONE must be set to match the system time zone.
看看官方这段的描述,所以当我们使用windows开发的时候,还是要注意以上的一些问题的。
Django基于Pycharm开发之三[LANGUAGE_CODE与TIME_ZONE]的更多相关文章
- Django基于Pycharm开发之三[命名空间 与过滤器]
关于命名空间的问题,在project项目中,我们可以设置路由类似于: from django.conf.urls import url,includefrom django.contrib impor ...
- Django基于Pycharm开发之二 [使用django adminSite]
在使用django自带的adminsite的时候,有以下内容需要做. 1.数据迁移,管理表的创建. 2.启用本地化 (setting.py的配置) 一.数据迁移,默认情况下,安装django之后,dj ...
- Django基于Pycharm开发之四[关于静态文件的使用,配置以及源码分析](原创)
对于django静态文件的使用,如果开发过netcore程序的开发人员,可能会比较容易理解django关于静态文件访问的设计原理,个人觉得,这是一个middlerware的设计,但是在django中我 ...
- Django基于Pycharm开发之一【创建django工程】
Django的工程结构,可以通过pycharm里面,选择创建django工程来直接创建,也可以通过命令行通过pip来安装. 一.通过命令行安装的步骤 Install Python. Install a ...
- 用pycharm开发django项目示例
pycharm开发django工程(一) 在pycharm(企业版)中新建Django工程,注意使用虚拟环境 创建成功后,在pycharm显示的工程目录结构如下: 打开pycharm的Termina ...
- PyCharm 开发Django ,错误汇总
近期略微接触了一下Django.在学习的过程中可谓是坎坎坷坷,遇到了很多的问题. 下面就来谈一谈我对Django的一点点的见解. Django项目的创建 使用PyCharm来开发Django项目是非常 ...
- pycharm+python+Django之web开发环境的搭建(windows)
转载:https://blog.csdn.net/yjx2323999451/article/details/53200243/ pycharm+python+Django之web开发环境的搭建(wi ...
- PyCharm社区版+Django搭建web开发环境-2
接上一篇:PyCharm社区版+Django搭建web开发环境-1 1. 创建好django项目并建立app应用:web 2. setting.py:配置app应用 INSTALLED_APPS = ...
- windows下使用pycharm开发基于ansible api的python程序
Window下python安装ansible,基于ansible api开发python程序 在windows下使用pycharm开发基于ansible api的python程序时,发现ansible ...
随机推荐
- AJPFX总结java创建线程的三种方式及其对比
Java中创建线程主要有三种方式: 一.继承Thread类创建线程类 (1)定义Thread类的子类,并重写该类的run方法,该run方法的方法体就代表了线程要完成的任务.因此把run()方法称为执行 ...
- Django的Serializers的使用
Serializer 在这里通过一个验证用户身份的例子说明rest_framework中serializer.Serialize的使用. 编写serializer Serializer的使用不需要依赖 ...
- vue指令总结(二)
一.vue指令 1.v-text v-text是用于操作纯文本,它会替代显示对应的数据对象上的值.当绑定的数据对象上的值发生改变,插值处的内容也会随之更新.注意:此处为单向绑定,数据对象上的值改变,插 ...
- docker使用centos7系统构建oraclejdk镜像
FROM centos:7.4.1708 MAINTAINER huqiang:2018/10/12 ENV JAVA_VERSION=8 \ JAVA_UPDATE=191 \ JAVA_BUILD ...
- LeetCode OJ 3Sum 3个整数之和
题意:给一个vector<int>容器,要求每当找到3个元素之和为0时就将这3个数按大小顺序记下来,用一个二维vector返回.也就是vector< vector<int> ...
- [习题] FindControl 简单练习--GridView + CheckBox,点选多列数据(复选删除)#3 List或数组
[习题] FindControl 简单练习--GridView + CheckBox,点选多列数据(复选删除)#3 List或数组 之前的范例,使用字符串.文字来记录将删除的文章ID 后续会有很多小缺 ...
- pat乙级1045
从左到右扫描时记录扫描到当前下标为止的最大值,如果当前元素大于这个最大值,那么它就大于它左边的所有值.同理,从右到左扫描记录扫描到当前下标为止的最小值,如果当前元素小于这个最大小值,那么它就小于它右边 ...
- SAP Cloud for Customer Extensibility的设计与实现
今天的文章来自Jerry的同事,SAP成都研究院C4C开发团队的开发人员徐欢(Xu Boris).徐欢就坐我左手边的位置,因此我工作中但凡遇到C4C的技术问题,一扭头就可以请教他了,非常方便.下图是他 ...
- 最好的 6 个 HTML5 的多媒体播放器
是 HTML5 中新引入的标签,用来在 Web 网页中嵌入视频播放功能,无需 Flash 和其他嵌入式插件的支持,是浏览器内建的功能,不过 旨在一些高级浏览器中支持,例如 Firefox, Sa ...
- Maven 虐我千百遍,我待 Maven 如初恋
前言 在如今的互联网项目开发当中,特别是Java领域,可以说Maven随处可见.Maven的仓库管理.依赖管理.继承和聚合等特性为项目的构建提供了一整套完善的解决方案,可以说如果你搞不懂Maven,那 ...