#654 closed defect (fixed)
DateFormat should be a subclass of TimeFormat, not Formatter
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Tools | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.utils.dateformat.DateFormat is currently a subclass of Formatter, not TimeFormat. As a result, calls to, e.g., dateformat.format will fail if they contain characters referencing units handled by TimeFormat.
Example traceback:
There's been an error: Traceback (most recent call last): File "/home/korpios/devel/py3p/django/core/handlers/base.py", line 68, in get_response response = callback(request, **param_dict) File "/home/korpios/devel/py3p/django/contrib/admin/views/decorators.py", line 49, in _checklogin return view_func(request, *args, **kwargs) File "/home/korpios/devel/py3p/django/contrib/admin/views/main.py", line 1110, in history }, context_instance=Context(request)) File "/home/korpios/devel/py3p/django/core/extensions.py", line 11, in render_to_response return HttpResponse(loader.render_to_string(*args, **kwargs)) File "/home/korpios/devel/py3p/django/core/template/loader.py", line 82, in render_to_string return t.render(context_instance) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 116, in render return self.nodelist.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 443, in render bits.append(node.render(context)) File "/home/korpios/devel/py3p/django/core/template/loader.py", line 161, in render return compiled_parent.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 116, in render return self.nodelist.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 443, in render bits.append(node.render(context)) File "/home/korpios/devel/py3p/django/core/template/loader.py", line 161, in render return compiled_parent.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 116, in render return self.nodelist.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 443, in render bits.append(node.render(context)) File "/home/korpios/devel/py3p/django/core/template/loader.py", line 106, in render result = self.nodelist.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 443, in render bits.append(node.render(context)) File "/home/korpios/devel/py3p/django/core/template/defaulttags.py", line 178, in render return self.nodelist_true.render(context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 443, in render bits.append(node.render(context)) File "/home/korpios/devel/py3p/django/core/template/defaulttags.py", line 111, in render nodelist.append(node.render(context)) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 473, in render output = resolve_variable_with_filters(self.var_string, context) File "/home/korpios/devel/py3p/django/core/template/__init__.py", line 418, in resolve_variable_with_filters obj = registered_filters[name][0](obj, arg) File "/home/korpios/devel/py3p/django/core/template/defaultfilters.py", line 317, in date return format(value, arg) File "/home/korpios/devel/py3p/django/utils/dateformat.py", line 238, in format return df.format(format_string) File "/home/korpios/devel/py3p/django/utils/dateformat.py", line 26, in format pieces.append(str(getattr(self, piece)())) AttributeError: DateFormat instance has no attribute 'P'
Solution: have django.utils.dateformat.DateFormat subclass TimeFormat.
Change History (2)
comment:1 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 17 years ago
Reporter: | changed from | to
---|
Note:
See TracTickets
for help on using tickets.
(In [976]) Fixed #654 -- Fixed bug in [969]. Thanks, korpios@…