how to use timezones for datetime fields that are foreign keys in admin interface
22 views
Skip to first unread message
dalupus
unread,
Sep 2, 2012, 8:47:31 PM9/2/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
So basically I have a Project object which has a bunch of Items like
so:
class Project(models.Model):
name = models.CharField(max_length=60)
datetime = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return unicode(self.datetime)
class Item(models.Model):
name = models.CharField(max_length=60)
created = models.ForeignKey(Project)
When I look at the Project the date appears correctly in TZ format.
On the item list screen however the datetime is not formated and seems
to be in utc format like so:
2012-09-03 00:28:21.664176+00:00
so it appears it is not adjusting to display the field in the users
timezone.
Any ideas how to get around this?
Melvyn Sopacua
unread,
Sep 8, 2012, 6:55:34 AM9/8/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Le lundi 3 septembre 2012 02:48:24 UTC+2, dalupus a écrit :
On the item list screen however the datetime is not formated and seems
to be in utc format like so:
2012-09-03 00:28:21.664176+00:00
so it appears it is not adjusting to display the field in the users
timezone.
Any ideas how to get around this?
In Django 1.5, you will be able to use django.utils.timezone.localtime().