Sunday, September 2, 2012

how to use timezones for datetime fields that are foreign keys in admin interface

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?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment