I don't know what exactly you need, but:
1) If you need Reminder.date always return Event.date - 7
import datetime
class Reminder(models.Model):
email = models.EmailField("e-mail")
event = models.ForeignKey(Event, unique=True, related_name='event',)
def date(self):
return self.event.date - datetime.timedelta(days=7)
class Event(models.Model):
date = models.DateTimeField(_(u"Event Date"), auto_now_add=True,)
2) If you need to set the date on event save or on reminder save, do this:
import datetime
class Reminder(models.Model):
email = models.EmailField("e-mail")
event = models.ForeignKey(Event, unique=True, related_name='event',)
date = models.DateTimeField(_(u"Remind date"), auto_now_add=False,)
# update date on save
def save(self, *args, **kwargs):
self.date = self.event.date - datetime.timedelta(days=7)
super(Reminder, self).save(*args, **kwargs)
class Event(models.Model):
date = models.DateTimeField(_(u"Event Date"), auto_now_add=True,)
# update all reminders on event save
def save(self, *args, **kwargs):
reminder_date = self.date - datetime.timedelta(days=7)
self.reminders.update(date=reminder_date)
super(Event, self).save(*args, **kwargs)
Please note that I haven't tested the code and there might be typos.