diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-09-15 09:14:51 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-09-15 09:14:51 +0000 |
| commit | 1baae32e16e8eee5bc239bfea8674651b765a41f (patch) | |
| tree | 0d397edb4300f99f8035583230fdedfa35882e28 /django | |
| parent | 84e824fbbf7b1c90e0d6191e8e69577cfce0664b (diff) | |
Fixed #4879 -- Added 'created' arg to post_save signal. This is True is a new object is created. Patch from George Vilches.
Fully backwards compatible, because signal receivers do not have to be able to accept all the arguments (thankyou, robust_apply()).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6269 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index f7b9069cce..fa1e0224d0 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -247,6 +247,7 @@ class Model(object): qn(self._meta.order_with_respect_to.column)) cursor.execute(subsel, (getattr(self, self._meta.order_with_respect_to.attname),)) db_values.append(cursor.fetchone()[0]) + record_exists = False if db_values: cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % \ (qn(self._meta.db_table), ','.join(field_names), @@ -261,7 +262,8 @@ class Model(object): transaction.commit_unless_managed() # Run any post-save hooks. - dispatcher.send(signal=signals.post_save, sender=self.__class__, instance=self) + dispatcher.send(signal=signals.post_save, sender=self.__class__, + instance=self, created=(not record_exists)) save.alters_data = True |
