Changing pub_date to DateField() class worked now and now I am able to see date values stored in the pub_date column.
On Sunday, February 3, 2013 9:07:27 AM UTC-5, Rootz wrote: > > I made several attempts to store/update the current date in a model. I > used both admin page and the shell to save/update a datetimefield value of > my model and then after querying the record it return None for > datetimefield column. > > Secondly my method was_published_recently() does not work. > > I am guessing maybe its because I am using sqlite3 correct me if I am > wrong? > > I am using sqlite3 db engine. > > models.py > > from django.db import models > import datetime > from django.utils import timezone > > > # Create your models here. > > class Poll(models.Model): > question = models.CharField(max_length=200) > pub_date = models.DateTimeField('Date Information') > > def __unicode__(self): > return self.question > > def was_published_recently(self): > return self.pub_date >= timezone.now() - datetime.timedelta(days=1) > > class Choice(models.Model): > poll = models.ForeignKey('Poll') > choice = models.CharField(max_length=200) > votes = models.IntegerField() > > def __unicode__(self): > return self.choice > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.