1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #24578 -- Fixed crash with QuerySet.update() on FK to O2O fields.

Thanks Anssi Kääriäinen for review.
This commit is contained in:
Tim Graham
2015-04-07 09:08:05 -04:00
parent 20a98d863f
commit a10b4c010a
3 changed files with 15 additions and 1 deletions

View File

@@ -878,7 +878,7 @@ class Model(six.with_metaclass(ModelBase)):
def prepare_database_save(self, field):
if self.pk is None:
raise ValueError("Unsaved model instance %r cannot be used in an ORM query." % self)
return getattr(self, field.remote_field.field_name)
return getattr(self, field.remote_field.get_related_field().attname)
def clean(self):
"""