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 <[EMAIL PROTECTED]> wrote: > 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 still has a Foo ptr id, so ultimately there is still > only one object. > that is, I think, the primary key that is accessed when using > Bar.objects.all() > > really, you have broken it by this self.id = None, > so I would expect more problems > > On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> 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 = 1) > > > This gives me, > > > In [1]: from djcalendar.models import Foo > > > In [2]: shabda = Foo(name = 'Shabda') > > > In [3]: shabda.save() > > > In [4]: Foo.objects.all() > > Out[4]: [<Foo: Foo object>] > > > In [5]: shabda.name = 'Shabda Raaj' > > > In [6]: shabda.save() > > > In [7]: Foo.objects.all() > > Out[7]: [<Foo: Foo object>, <Foo: Foo object>] > > > Which is what I expect. Now doing the same thing to Bar > > > In [1]: from djcalendar.models import Bar > > > In [2]: shabda = Bar(name = 'Shabda') > > > In [3]: shabda.save() > > > In [4]: shabda.name = 'Shabda Raaj' > > > In [5]: shabda.save() > > > In [6]: Bar.objects.all() > > Out[6]: [<Bar: Bar object>] > > > Here I am expecting two objects, similar to what happened with Foo, > > but I get only one. > > > Am I missing something, or is this a bug? --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---