On Wed, Jan 14, 2009 at 12:51 PM, Sebastian Bauer <ad...@ugame.net.pl>wrote:
> > Hi > > I think it's a bug, but maybe im wrong: > > > print Categories.objects.count() > >>0 > new_obj = Categories.objects.create(name="test") > instance_1 = Categories.objects.get(pk=new_obj.pk) > instance_2 = Categories.objects.get(pk=new_obj.pk) > > instance_1.delete() > print Kategorie.objects.count() > >>0 > instance_2.save() > print Kategorie.objects.count() > >>1 > > how orm can save second instance of the same row when its deleted? > > i have 2 options to solve this problem: > > 1. create method of Model instance to check if row exists and let users > to handle it by own > or > 2. throw exception ex. models.DoesNotExist > > what you think about this problem? > If you want to make sure a save() only updates an existing row and never inserts a new row, pass in force_update=True on the save: http://docs.djangoproject.com/en/dev/ref/models/instances/#forcing-an-insert-or-update Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---