Ticket #4879: post_save_with_created_kw_r5991.patch

File post_save_with_created_kw_r5991.patch, 1.0 KB (added by George Vilches <gav@…>, 8 years ago)

Updated patch for post_save created signal against r5991.

  • django/db/models/base.py

    old new class Model(object): 
    245245                placeholders.append('(SELECT COUNT(*) FROM %s WHERE %s = %%s)' % \
    246246                    (qn(self._meta.db_table), qn(self._meta.order_with_respect_to.column)))
    247247                db_values.append(getattr(self, self._meta.order_with_respect_to.attname))
     248            record_exists = False
    248249            if db_values:
    249250                cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % \
    250251                    (qn(self._meta.db_table), ','.join(field_names),
    class Model(object): 
    259260        transaction.commit_unless_managed()
    260261
    261262        # Run any post-save hooks.
    262         dispatcher.send(signal=signals.post_save, sender=self.__class__, instance=self)
     263        dispatcher.send(signal=signals.post_save, sender=self.__class__, instance=self, created=(not record_exists))
    263264
    264265    save.alters_data = True
    265266
Back to Top