awesto / django-shop

A Django based shop system
http://www.django-shop.org
BSD 3-Clause "New" or "Revised" License
3.17k stars 1.04k forks source link

add optional attr `prev_cur_next_products` for `ProductRetrieveView` #797

Closed haricot closed 4 years ago

haricot commented 4 years ago

related #734 Peek 14-03-2020 15-19

with django-shop1.2 and polymorphic and djangorestframework==3.9.2: With prev_cur_next_products = False, it finds product.product_code with SmartPhoneModel, SmartCard, Commodity. but: With prev_cur_next_products = True, there is a bug when i try view with product SmartPhoneModel, it does not find the product.product_code, whereas it finds it for SmartCard, Commodity. (Currently not available) Capture d’écran du 2020-03-14 15-32-30

backoffice error:

  File "/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/python3.8/site-packages/cms/utils/decorators.py", line 20, in inner
    return func(request, *args, **kwargs)
  File "/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/python3.8/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/python3.8/site-packages/rest_framework/views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "/python3.8/site-packages/rest_framework/views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/python3.8/site-packages/rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "/haricot/.cache/pypoetry/virtualenvs/my-shop-et1pgCPw-py3.8/src/django-shop/shop/views/catalog.py", line 225, in get
    serializer = self.serializer_class(context=context, **kwargs)
  File "/haricot/.cache/pypoetry/virtualenvs/my-shop-et1pgCPw-py3.8/src/django-shop/shop/serializers/defaults/catalog.py", line 46, in __init__
    instance = self.get_instance(context, data, kwargs)
  File "/haricot/.cache/pypoetry/virtualenvs/my-shop-et1pgCPw-py3.8/src/django-shop/shop/serializers/defaults/catalog.py", line 92, in get_instance
    'product_code': product.product_code,
haricot commented 4 years ago

Closed in flavor of better approach.