i am trying to implement a save function on a model class that inherits from an abstract base class. what i am trying to do is set the field in the base class only if it isn't already set.
i have the following: class Base(models.Model): attribute = models.ForeignKey('Attribute', db_index=True) class Meta: abstract = True class Child1(Base): ... stuff here ... class Child2(Base): child1 = models.ForeignKey(Child1) def save1(self, force_insert=False, force_update=False): if not self.attribute: self.attribute = self.player.attribute super(Report, self).save(force_insert, force_update) def save2(self, force_insert=False, force_update=False): self.attribute = self.child1.attribute super(Report, self).save(force_insert, force_update) if i use save1 as my save function, i get the following: File "/Users/greer/projects/django/...", line 346, in save if not self.casino: File "/Library/Python/2.5/site-packages/django/db/models/fields/related.py", line 235, in __get__ raise self.field.rel.to.DoesNotExist DoesNotExist if i use save2 as my save function, it works just fine. however, if attribute is already set, i don't want to override it with the attribute from child1. any ideas on how to set attribute only if it isn't already set? thanks in advance, rusty --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---