Opened 16 years ago

Last modified 16 years ago

#9090 closed

A problem with WEEKDAYS_ABBR in dates.py (Django version 1.0) — at Initial Version

Reported by: Leo Putkonen Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords: dates.py, WEEKDAYS_ABBR
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I noticed this problem while playing around with Django tutorial (part 2).

A button in the admin site interface calls WEEKDAYS_ABBR in dates.py and raises ImportError. This happens because WEEKDAYS_ABBR is not defined in dates.py located at /site-packages/django/utils/

A simple fix is to add a couple of lines to dates.py

WEEKDAYS_ABBR = {
    0:_('Mon'), 1:_('Tue'), 2:_('Wed'), 3:_('Thu'), 4:_('Fri'),
    5:_('Sat'), 6:_('Sun')
}

Complete Traceback:

Django version 1.0-final-SVN-unknown, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[15/Sep/2008 05:52:08] "GET /admin/ HTTP/1.1" 200 3398
Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 277, in run

self.result = application(self.environ, self.start_response)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 634, in call

return self.application(environ, start_response)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 239, in call

response = self.get_response(request)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py", line 128, in get_response

return self.handle_uncaught_exception(request, resolver, exc_info)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py", line 148, in handle_uncaught_exception

return debug.technical_500_response(request, *exc_info)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/views/debug.py", line 39, in technical_500_response

html = reporter.get_traceback_html()

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/views/debug.py", line 113, in get_traceback_html

return t.render(c)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/init.py", line 176, in render

return self.nodelist.render(context)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/init.py", line 768, in render

bits.append(self.render_node(node, context))

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/debug.py", line 81, in render_node

raise wrapped

TemplateSyntaxError: Caught an exception while rendering: cannot import name WEEKDAYS_ABBR

Original Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node

result = node.render(context)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/debug.py", line 87, in render

output = force_unicode(self.filter_expression.resolve(context))

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/init.py", line 559, in resolve

new_obj = func(obj, *arg_vals)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/template/defaultfilters.py", line 626, in date

from django.utils.dateformat import format

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/utils/dateformat.py", line 14, in <module>

from django.utils.dates import MONTHS, MONTHS_3, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR

ImportError: cannot import name WEEKDAYS_ABBR

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top