Reputation: 41433
i have a model which holds data for a game, how would i add 2 hours and 1 day onto the 'starts' field?
class Game(models.Model):
starts = models.DateTimeField(auto_now_add=True)
ends = models.DateTimeField()
does anyone have a solution for this?
Upvotes: 8
Views: 10991
Reputation: 31951
from datetime import timedelta
obj.starts += timedelta(days=1, hours=2)
Upvotes: 21