Skip to content

Commit

Permalink
[Fix] Resolve product class updating to None in Django 3.2 (#12)
Browse files Browse the repository at this point in the history
* fix 🐛 resolve product class updating to None in django 3.2

* refactor 📦 use existing method from base.Model
  • Loading branch information
samar-hassan authored Jan 26, 2024
1 parent c40556a commit 178fa79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 3 additions & 0 deletions oscar_odin/mappings/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def bulk_update_or_create_instances(self, instances):

fields = self.get_fields_to_update(self.Model)
if fields is not None:
for instance in instances_to_update:
# This should be removed once support for django 3.2 is dropped
instance._prepare_related_fields_for_save("bulk_update")
self.Model.objects.bulk_update(instances_to_update, fields=fields)

def bulk_update_or_create_one_to_many(self):
Expand Down
9 changes: 3 additions & 6 deletions oscar_odin/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from collections import defaultdict
import contextlib
import time
import math

from django.db import connection, reset_queries

from collections import defaultdict

from django.db.models import Model, ManyToManyField, ForeignKey, Q
from django.db import connections
from django.db import connection, connections, reset_queries
from django.db.models import Q


def get_filters(instances, field_names):
Expand Down

0 comments on commit 178fa79

Please sign in to comment.