hey folks, I have two models: _______________________________________________________ class contentcreator(models.Model): name = models.CharField(max_length=50) phone = models.CharField(max_length=60, blank=True) supervisor = models.CharField(max_length=60) department = models.CharField(max_length=60, blank=True) def __unicode__(self): return self.name
class Meta: verbose_name = u'Content Creator' verbose_name_plural = u'Content Creators' class accuracyreport(models.Model): byline = models.ForeignKey(contentcreator, related_name="byline") date = models.DateField() resolved = models.BooleanField("Resolved?", help_text="Has the issue been resolved?", null=True) responsible = models.ForeignKey(contentcreator, related_name="ultimately_responsible", blank=True, null=True) supervisor = models.CharField(max_length=60, editable=False) def save(self): if not self.responsible: self.supervisor = contentcreator.objects.get (name__exact=self.byline).supervisor else: self.supervisor = contentcreator.objects.get (name__exact=self.responsible).supervisor super(accuracyreport, self).save() _______________________________________________________ The custom save(), as you can probably tell, is where I'm having trouble. I'd like to set things so that when the "responsible" field is blank, the supervisor of the byline gets saved in the accuracyreport model. If it's filled in, then the supervisor of "responsible" gets filled in. I'm aware of the denormalization issues, but I think it's the best way to handle this particular problem. Help? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---