Skip to content

Commit

Permalink
Fix: Use .set() to update reverse many-to-many
Browse files Browse the repository at this point in the history
  • Loading branch information
evenicoulddoit committed Jan 3, 2018
1 parent 58d7fa1 commit 45c4db3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_auto_optimise.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ def give_all_owners_all_skus(self):
skus = test_models.Sku.objects.all()

for owner in test_models.Owner.objects.all():
owner.cars = skus
owner.save()
# TODO: Remove catch after dropping 1.8 support
try:
owner.cars.set(skus)
except AttributeError:
owner.cars = skus
owner.save()

def get_view_instance(self, view_class, **kwargs):
view = self.get_instance(view_class, **kwargs)
Expand Down

0 comments on commit 45c4db3

Please sign in to comment.