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
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
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
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
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
5 matches
Mail list logo