Over ride the save() method on teh Actions: class Actions(models.Model):
date_start_preview = models.DateField('Data Prevista Inicial', blank=True) date_end_preview = models.DateField('Data Prevista Final', blank=True) date_start = models.DateField('Data Real Inicial', blank=True) date_end = models.DateField('Data Real Final', blank=True) actionplan = models.ForeignKey(Actionplan, verbose_name='Ações', related_name='actions') def save(self, *args, **kwargs): # if you want the time "now" self.actionplan.date_start = datetime.datetime.now() # OR if you want the time to be the same as in the action: # self.actionplan.date_start = self.date_start # etc etc, do same for each var super(Actions, self).save(*args, **kwargs) (check syntax if you need Timezones: https://docs.djangoproject.com/en/1.8/topics/i18n/timezones/ , and here are the docs on method overriding: https://docs.djangoproject.com/en/1.8/topics/db/models/#overriding-predefined-model-methods ) cheers L. ------ let's build quiet armies friends, let's march on their glass towers...let's build fallen cathedrals and make impractical plans - GYBE On 3 June 2015 at 00:37, Juliano Araújo Farias <bello.lichtgest...@gmail.com > wrote: > Dears, > > First I thx for ur attentions... and I novete in Django... but a have a > question... > > Second: > I have this in my model: > > class Actionplan(models.Model): > > date_start_preview = models.DateField('Data Prevista Inicial', > blank=True, null=True) > date_end_preview = models.DateField('Data Prevista Final', blank=True, > null=True) > date_start = models.DateField('Data Real Inicial', blank=True, > null=True) > date_end = models.DateField('Data Real Final', blank=True, null=True) > > class Actions(models.Model): > > date_start_preview = models.DateField('Data Prevista Inicial', > blank=True) > date_end_preview = models.DateField('Data Prevista Final', blank=True) > date_start = models.DateField('Data Real Inicial', blank=True) > date_end = models.DateField('Data Real Final', blank=True) > > actionplan = models.ForeignKey(Actionplan, verbose_name='Ações', > related_name='actions') > > > ----------------------- > and I want in admin do: > > When the user create a action, the dates in actionplans update with the > sum dates... > > > thx a lot... > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/2309e9e6-8289-4ea6-865e-9095bddb9fe8%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/2309e9e6-8289-4ea6-865e-9095bddb9fe8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiM0Lp1xfgx9JfvAr%3DuK86LPvgTpiYXbLtgGJJUokF51_g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.