This script generate fake dates for seens that has not hour minute and

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
"""
This script generate fake dates for seens that has not hour, minute and values.
You should disabled auto_now argument of seen.date before running the script.
"""
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from datetime import timedelta
from movie.models import Seen
for seen in Seen.objects.all():
if '00-00-00' == seen.date.strftime('%H-%M-%S'):
old_date = seen.date
seen.date = seen.date + timedelta(seconds=seen.id)
seen.save()
print '%s --> %s' % (old_date, seen.date)