Opened 17 years ago

Closed 12 years ago

Last modified 12 years ago

#4076 closed New feature (fixed)

Patch to Output Timezone in Date Fields for Atom Feeds

Reported by: Alastair Tse <alastair@…> 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)

django-svn-feedgenerator-timezone.patch (619 bytes ) - added by Alastair Tse <alastair@…> 17 years ago.

Download all attachments as: .zip

Change History (11)

by Alastair Tse <alastair@…>, 17 years ago

comment:1 by Alastair Tse <alastair@…>, 17 years ago

Cc: alastair@… added

comment:2 by Thomas Kerpe, 17 years ago

Needs documentation: set
Triage Stage: UnreviewedAccepted

comment:3 by Thomas Kerpe, 17 years ago

Keywords: sprintsept14 added
Needs documentation: unset
Owner: changed from nobody to Thomas Kerpe
Status: newassigned

Looks reasonable OK for me...

comment:4 by Thomas Kerpe, 17 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [6233]

comment:5 by max klymyshyn, 15 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:

comment:6 by anonymous, 14 years ago

Has patch: unset
Resolution: fixed
Status: closedreopened
Version: SVN1.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

in reply to:  6 comment:7 by wiboshu, 14 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 Łukasz Rekucki, 13 years ago

Severity: Normal
Type: New feature

comment:9 by Aymeric Augustin, 12 years ago

Easy pickings: unset
Resolution: fixed
Status: reopenedclosed
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.

comment:10 by Aymeric Augustin, 12 years ago

In [16989]:

Ensured that the feeds framework supports both datetimes and dates. Refs #4076.

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