Thank you Mengu. I have tried what you suggested (I was concatenating the date to the updated field instead) but the problem is that every time there is a save the date gets added even though the field has not changed. So I wanted to test if the field was changed and if so concatenate the date to it if not I would do nothing. Thanks for taking the time to respond to my question. Much appreciated.
On Apr 17, 11:01 am, Mengu <whalb...@gmail.com> wrote: > i believe it does. you can override the "save" method of your model > like this: > > from django.db import models > from datetime import datetime > > # Create your models here. > class TestModel(models.Model): > first_field = models.CharField(max_length=255) > second_field = models.BooleanField() > updated_at = models.DateTimeField(default=datetime.now) > > def save(self, *args, **kwargs): > if hasattr(self, 'id') and getattr(self, 'id') is not None: > self.updated_at = datetime.now() > super(TestModel, self).save(*args, **kwargs) > > On Apr 17, 6:25 pm, Aref <arefnamm...@gmail.com> wrote: > > > Hello, > > > I have a text field which could be updated regularly and I want to > > automatically attach a date every time the record is updated--but only > > if the record is updated. Can this be done in django and how would I > > go about doing it. > > Thanks. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.