Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions oscarapi/serializers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
from django.db import models
from django.db.models.manager import Manager
from django.db.models.constants import LOOKUP_SEP

from rest_framework import serializers

import oscar.models.fields

from oscarapi.utils.exists import construct_id_filter
from .fields import ImageUrlField
from oscarapi.utils.loading import get_api_class

ImageUrlField = get_api_class("serializers.fields", "ImageUrlField")
logger = logging.getLogger(__name__)


Expand Down
4 changes: 3 additions & 1 deletion oscarapi/tests/unit/testserializers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.db import models
from django.test import TestCase
from oscarapi.serializers.utils import ImageUrlField
from rest_framework.fields import ImageField
from oscarapi.utils.loading import get_api_class

ImageUrlField = get_api_class("serializers.fields", "ImageUrlField")


class SerializerstTest(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions oscarapi/utils/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from rest_framework.fields import MISSING_ERROR_MESSAGE
from rest_framework.exceptions import ErrorDetail
from oscarapi.utils.loading import get_api_class
from oscarapi.serializers import fields as oscarapi_fields

ImageUrlField = get_api_class("serializers.fields", "ImageUrlField")
attribute_details = operator.itemgetter("code", "value")
entity_internal_value = get_api_class("serializers.hooks", "entity_internal_value")

Expand Down Expand Up @@ -57,7 +57,7 @@ def to_attribute_type_value(self, attribute, code, value):
elif attribute.type == attribute.ENTITY:
internal_value = entity_internal_value(attribute, value)
elif attribute.type in [attribute.IMAGE, attribute.FILE]:
image_field = oscarapi_fields.ImageUrlField()
image_field = ImageUrlField()
# pylint: disable=protected-access
image_field._context = self.context
internal_value = image_field.to_internal_value(value)
Expand Down