Instead of manually setting the update time and created date, as it  
seems like you mean to do here, I highly recommend auto_now and now  
auto_now_add attributes that you can add to your date fields, to get  
this functionality for free.  See 
http://docs.djangoproject.com/en/dev/ref/models/fields/#datetimefield

/Håkan

4 nov 2008 kl. 22.41 skrev Antonio Cavedoni:

>
> Ciao Antonio,
>
> On Nov 4, 2008, at 8:58 PM, Antonio Volpon wrote:
>> import datetime
>> from django.db import models
>>
>> class Object(models.Model):
>>   description = models.CharField(max_length=255)
>>   insert_date = models.DateTimeField(editable=False)
>>   update_date = models.DateTimeField(editable=False)
>>
>>   def save(self):
>>       if not self.id:
>>           self.insert_date = datetime.date.today()
>>       self.update_time = datetime.date.today()
>>       super(Object, self).save()
>
> you have a field called update_date but then you reference it as
> self.update_time in the save() method, maybe that’s why it isn’t
> working?
>
> Cheers!
> -- 
> Antonio
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to