Re: Adding fields to model objects that don't correspond to database state

2009-02-08 Thread Alex Koshelev
try this: def attach_bar(self, bar): if getattr(self, "bars", None) is None: self.bars = [] self.bars.append(bar) On Mon, Feb 9, 2009 at 12:03 AM, Jack Orenstein wrote: > > I have a model object that looks something like this: > > class Foo(models.Model)

Adding fields to model objects that don't correspond to database state

2009-02-08 Thread Jack Orenstein
I have a model object that looks something like this: class Foo(models.Model) foo_id = models.IntegerField(primary_key = True) xyz = models.CharField(max_length = 20) In my application, I'd like to add a list of Bar objects. It's like a foreign key, except that Bar objects don