Django 1.2 admin - 日期时间小部件无法正常工作吗?
如果您在管理员中有一个日期时间字段,并且调用“今天”链接,它似乎会从 calendar.js
抛出异常,其中引用了未定义的全局方法 get_format
。这似乎没有在任何最新的管理 js 文件中定义。
编辑:
看起来它使用的是与系统上的标准 django 1.1 不同的 i18n.py
文件。这是我的 wsgi 文件:
import os, sys, site
site.addsitedir( '/srv/python-environments/django1point2/lib/python2.5/site-packages')
sys.path.append('/srv/')
sys.path.append('/srv/workarounds')
os.environ['DJANGO_SETTINGS_MODULE'] = 'workarounds.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我需要更改什么才能使其依赖于我指定的 addsitedir 字符串中的 i18n.py
而不是系统默认值?
If you have a date time field within the admin, and you invoke the "Today" link it seems it throws an exception from calendar.js
where it references an undefined global method get_format
. This doesn't seem to be defined in any of the latest admin js files.
Edit:
It seems like it was using a different i18n.py
file from my standard django 1.1 on the system. Here's my wsgi file:
import os, sys, site
site.addsitedir( '/srv/python-environments/django1point2/lib/python2.5/site-packages')
sys.path.append('/srv/')
sys.path.append('/srv/workarounds')
os.environ['DJANGO_SETTINGS_MODULE'] = 'workarounds.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
What do I need to alter so it relies on the i18n.py
in the addsitedir string I specify instead of my system default?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 .wsgi 代码将 virtualenv 站点包放在系统站点包之后,因此全局包将优先。我使用以下代码段(来自 mod_wsgi 有关与 virtualenv 一起使用的文档,其中我建议)将 virtualenv 站点包放在第一位:
Your .wsgi code puts the virtualenv site-packages after the system site-packages, so global packages will take priority. I use the following snippet (from the mod_wsgi documentation on use with virtualenv, which I recommend) to put the virtualenv site-packages first:
管理小部件在正常情况下肯定确实工作(我在 Django trunk、1.2 和 1.2.1 下使用过它)。问题是“你的情况有何不同?”
郑重声明,您正在寻找的函数 在此处定义。
我的第一个想法是,也许您修改了管理模板,并且没有包含适当的脚本。第二个想法可能是您在某处有旧文件的缓存版本。
v1.2 中的 javascript i18n 框架和本地化机制发生了很多变化,因此最好从您正在使用的设置开始。
总而言之,您需要提供更多信息才能获得有用的答案。
The admin widget most certainly does work under normal circumstances (I've used it under Django trunk, 1.2 and 1.2.1). The question is "what's different about your situation?"
For the record, the function you're looking for is defined here.
My first thought is perhaps you modified your admin templates and the appropriate scripts are not being included. Thought number two is perhaps you have a cached version of an old file somewhere.
There were quite a lot of changes to the javascript i18n framework and localization machinery in v1.2, so it may be best to start with what settings you're using.
All in all, you're going to need to give a lot more information in order to get a useful answer.