Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread Malcolm Tredinnick
On Sun, 2008-10-12 at 00:16 -0700, shabda wrote: > My models.py > > class Foo(models.Model): > name = models.CharField(max_length = 100) > > def save(self): > self.id = None > super(Foo, self).save() > > class Bar(Foo): > created = models.DateTimeField(auto_now_add

Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread felix
ah ok. you will have problems here because the parent class also has a database record and an id. it would be messy I think to try to fool django. better would be to make a kind of save_as or maybe you can copy the object and it will also copy its parent class. or make a specific method

Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread shabda
As long as model_obj.id is None, Django does an Insert, I want an insert to happen all the time. (Sort of like trying to get FullHistory, wherein I can roll back my object to a previous state. I can do save(force_insert = True), but that also gives me an Exception.) On Oct 12, 6:32 pm, felix

Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread felix
well this is interesting and curious what you are trying to do. why are you trying to do this self.id= None ? what is the real world purpose ? can you give a non abstract example ? in any case since Bar is a subclass of Foo there are two database tables. you set Bar id to None, but the object

Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread shabda
My models.py class Foo(models.Model): name = models.CharField(max_length = 100) def save(self): self.id = None super(Foo, self).save() class Bar(Foo): created = models.DateTimeField(auto_now_add = 1) This gives me, In [1]: from djcalendar.models import Foo In