Ticket #5309: query.py.2.diff

File query.py.2.diff, 1.3 KB (added by David Cramer <dcramer@…>, 17 years ago)
  • django/django/db/models/query.py

     
    262262        if len(obj_list) < 1:
    263263            raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name
    264264        assert len(obj_list) == 1, "get() returned more than one %s -- it returned %s! Lookup parameters were %s" % (self.model._meta.object_name, len(obj_list), kwargs)
    265         return obj_list[0]
     265        obj = obj_list[0]
     266        obj._is_stored = True
     267        return obj
    266268
    267269    def create(self, **kwargs):
    268270        """
     
    270272        and returning the created object.
    271273        """
    272274        obj = self.model(**kwargs)
     275        obj._is_stored = False
    273276        obj.save()
    274277        return obj
    275278
     
    287290            params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
    288291            params.update(defaults)
    289292            obj = self.model(**params)
     293            obj._is_stored = False
    290294            obj.save()
    291295            return obj, True
    292296
     
    11781182                    setattr(instance, field.attname, None)
    11791183
    11801184            setattr(instance, cls._meta.pk.attname, None)
     1185            instance._is_stored = False
    11811186            dispatcher.send(signal=signals.post_delete, sender=cls, instance=instance)
    11821187
    11831188    transaction.commit_unless_managed()
Back to Top