Hi, The declarative attribute 'auto_now' (as well as 'auto_now_add') is deprecated and its support will eventually be dropped. To achieve that you need to override the 'save' method. In that same method you can also call the parent's 'save' method to propagate the change to the ancestors:
ModelA(models.Model): modified = models.DateTimeField() parent = models.ForeignKey('self', related_name='children', null=True, blank=True) def save(def): self.modified = datetime.now() if self.parent: self.parent.save() super(ModelA, self).save() On Jul 20, 6:28 pm, "Andre Meyer" <[EMAIL PROTECTED]> wrote: > hi all > > i have a model with a modifed field > > modified = models.DateTimeField(auto_now=True) > > and a parent field > > parent = models.ForeignKey('self', related_name='children', null=True, > blank=True) > > in order to allow for creating a tree of items. > > what is the best way to propagate a modification in a child to set all its > parents to the same modification time? > > or is it possible to sort a query set that retrieves only the top-most items > (parent=None) on the latest modification time of its children? maybe using a > method that calculates and returns that date on the fly? > > thanks a lot for your help > André > > using trunk 8004, full code is > here<http://code.google.com/p/pastiche/source/browse> > . --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---