Skip to content

Commit

Permalink
queryset-refactor: Fixed an oversight in Model.save() that was preven…
Browse files Browse the repository at this point in the history
…ting updates to parent models beyond the initial save. Fixed #6706.

git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7218 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Mar 11, 2008
1 parent f2f9334 commit df8e3e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django/db/models/base.py
Expand Up @@ -268,7 +268,7 @@ def save(self, raw=False, cls=None):
self.save(raw, parent) self.save(raw, parent)
setattr(self, field.attname, self._get_pk_val(parent._meta)) setattr(self, field.attname, self._get_pk_val(parent._meta))


non_pks = [f for f in self._meta.local_fields if not f.primary_key] non_pks = [f for f in meta.local_fields if not f.primary_key]


# First, try an UPDATE. If that doesn't update anything, do an INSERT. # First, try an UPDATE. If that doesn't update anything, do an INSERT.
pk_val = self._get_pk_val(meta) pk_val = self._get_pk_val(meta)
Expand Down
4 changes: 3 additions & 1 deletion tests/modeltests/model_inheritance/models.py
Expand Up @@ -128,7 +128,9 @@ def __unicode__(self):
>>> r.save() >>> r.save()
# Test the constructor for ItalianRestaurant. # Test the constructor for ItalianRestaurant.
>>> ir = ItalianRestaurant(name='Ristorante Miron', address='1234 W. Elm', serves_hot_dogs=False, serves_pizza=False, serves_gnocchi=True, rating=4) >>> ir = ItalianRestaurant(name='Ristorante Miron', address='1234 W. Ash', serves_hot_dogs=False, serves_pizza=False, serves_gnocchi=True, rating=4)
>>> ir.save()
>>> ir.address = '1234 W. Elm'
>>> ir.save() >>> ir.save()
# Make sure Restaurant and ItalianRestaurant have the right fields in the right # Make sure Restaurant and ItalianRestaurant have the right fields in the right
Expand Down

0 comments on commit df8e3e6

Please sign in to comment.