开发者

Django 1.2 admin - are the datetime widgets not working properly? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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, si开发者_StackOverflowte

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?


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:

ALLDIRS = [os.path.join(virtenv, 'lib',
                                 'python%s' % sys.version[:3],
                                 'site-packages')]

# Remember original sys.path.
prev_sys_path = list(sys.path)

# Add project directory
sys.path.append(project)

# Add each new site-packages directory.
for directory in ALLDIRS:
  site.addsitedir(directory)

# Reorder sys.path so new directories at the front.
new_sys_path = []
for item in list(sys.path):
    if item not in prev_sys_path:
        new_sys_path.append(item)
        sys.path.remove(item)
sys.path[:0] = new_sys_path


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜