From 1b7ec90f45afce07b124b93cfce287ef19c7f0d1 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Fri, 22 Dec 2017 21:56:25 +0800 Subject: [PATCH] Switch to set method for modifying manytomany fields --- project/tests/test_lib/mock_suite.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/project/tests/test_lib/mock_suite.py b/project/tests/test_lib/mock_suite.py index 64be9271..18924fae 100644 --- a/project/tests/test_lib/mock_suite.py +++ b/project/tests/test_lib/mock_suite.py @@ -5,6 +5,7 @@ import random import traceback +import django from django.core import management from django.utils import timezone @@ -100,7 +101,10 @@ def mock_sql_queries(self, request=None, profile=None, n=1, as_dict=False): for q in queries: profile['queries'].append(q) else: - profile.queries = queries + if django.VERSION >= (1, 9): + profile.queries.set(queries) + else: + profile.queries = queries profile.save() return queries