#4076 closed New feature (fixed)
Patch to Output Timezone in Date Fields for Atom Feeds
Reported by: | Owned by: | Thomas Kerpe | |
---|---|---|---|
Component: | contrib.syndication | Version: | 1.1 |
Severity: | Normal | Keywords: | sprintsept14 |
Cc: | alastair@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, django.utils.feedgenerator outputs date strings for Atom 1.0 feeds without timezone information. For datetime objects that have tzinfo infor set, we should output the UTC offset if present. The patch attach will simply check whether tzinfo is set to something other than None, and thus have a valid timezone UTF offset that can be shown via strftime().
Attachments (1)
Change History (11)
by , 18 years ago
Attachment: | django-svn-feedgenerator-timezone.patch added |
---|
comment:1 by , 18 years ago
Cc: | added |
---|
comment:2 by , 17 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 17 years ago
Keywords: | sprintsept14 added |
---|---|
Needs documentation: | unset |
Owner: | changed from | to
Status: | new → assigned |
comment:5 by , 16 years ago
I don't understand what is wrong, but i had some trouble with django/utils/feedgenerator.py.
Error output is:
Exception Value: 'datetime.date' object has no attribute 'tzinfo' Exception Location: /Users/gabonsky/Bin/dist/django/django/utils/feedgenerator.py in rfc2822_date, line 29 Python Executable: /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python Python Version: 2.5.1
Here is patch for django/django/utils/feedgenerator.py:
29c29 < if date.tzinfo: --- > if hasattr(date, 'tzinfo') and date.tzinfo:
follow-up: 7 comment:6 by , 15 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Version: | SVN → 1.1 |
Same problem here:
Code:
def items(self): return Entry.objects.filter(is_published=True, pub_date__lte=datetime.date.today()).order_by('-pub_date')[:5]
Error:
Exception Type: AttributeError Exception Value: 'datetime.date' object has no attribute 'tzinfo' Exception Location: /Library/Python/2.6/site-packages/django/contrib/syndication/feeds.py in get_feed, line 148 Python Executable: /usr/bin/python Python Version: 2.6.1
comment:7 by , 15 years ago
Replying to anonymous:
Same problem here:
Code:
def items(self): return Entry.objects.filter(is_published=True, pub_date__lte=datetime.date.today()).order_by('-pub_date')[:5]Error:
Exception Type: AttributeError Exception Value: 'datetime.date' object has no attribute 'tzinfo' Exception Location: /Library/Python/2.6/site-packages/django/contrib/syndication/feeds.py in get_feed, line 148 Python Executable: /usr/bin/python Python Version: 2.6.1
You may have used DateField in the model incorrectly.Use DateTimeField instead.
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:9 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
UI/UX: | unset |
As mentioned by wiboshu, you're using a DateField
for pub_date
, rather than a DateTimeField
.
There's no reason to reject dates here. Indeed, it was a regression introduced in r6233. However, it was fixed as a side effect of #15503.
I'm going to add tests.
Please reopen if you still encounter the issue, with enough information to reproduce it.
Looks reasonable OK for me...