awesto / django-shop

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

ImportErrors after updating to django-rest-framework v3.7.0 #664

Open abannerjee opened 6 years ago

abannerjee commented 6 years ago

Django rest framework recently updated to version 3.7.0 (Release notes) and it seems some changes are causing django-shop to break.

First error encountered:

ImportError: Could not import 'rest_framework.filters.DjangoFilterBackend' for API setting 'DEFAULT_FILTER_BACKENDS'. AttributeError: 'module' object has no attribute 'DjangoFilterBackend'

From the release notes:

Removed DjangoFilterBackend inline with deprecation policy. Use django_filters.rest_framework.FilterSet and/or django_filters.rest_framework.DjangoFilterBackend

This issue was easily resolved by updating DEFAULT_FILTER_BACKENDS in the REST_FRAMEWORK settings.

Second error encountered:

...
  File "/Users/abannerjee/.virtualenvs/shop-core/lib/python2.7/site-packages/shop/rest/renderers.py", line 7, in <module>
    from rest_framework.compat import template_render
ImportError: cannot import name template_render

According to the release notes, django-rest-framework removes Django 1.8 and 1.9 support (see commit). From the commit we see the 'template_render' function has been removed from rest_framework.compat.

jrief commented 6 years ago

Please stick with version 3.6.3 of DRF for now.

lampwins commented 6 years ago

@jrief would you mind elaborating on this? I am running into this issue (outside of this project) and am looking for a reason because it is actually hit for miss for me. 3.7.1 sometimes works depending on the system. I am really scratching my head at this point.

jrief commented 6 years ago

what's the point of sticking with 3.6.3 for now? I recently ported django-SHOP to Django-1.11 and Python-3.6

jrief commented 6 years ago

@lampwins Finally I found some time to fix this. Please retry with the HEAD of branch releases/0.11.x. If everything works for you, I'll merge and release a new version.

lecharfly commented 6 years ago

I also encountered the same problem, the version also decreased 3.6.3, but still the same error, begging the great god support

jrief commented 6 years ago

which commit hash/version are you using? You may try the 0.12-branch, there it's fixed for sure.

praveenk-telsiz commented 5 years ago

Django rest framework recently updated to version 3.7.0 (Release notes) and it seems some changes are causing django-shop to break.

First error encountered:

ImportError: Could not import 'rest_framework.filters.DjangoFilterBackend' for API setting 'DEFAULT_FILTER_BACKENDS'. AttributeError: 'module' object has no attribute 'DjangoFilterBackend'

From the release notes:

Removed DjangoFilterBackend inline with deprecation policy. Use django_filters.rest_framework.FilterSet and/or django_filters.rest_framework.DjangoFilterBackend

This issue was easily resolved by updating DEFAULT_FILTER_BACKENDS in the REST_FRAMEWORK settings.

Second error encountered:

...
  File "/Users/abannerjee/.virtualenvs/shop-core/lib/python2.7/site-packages/shop/rest/renderers.py", line 7, in <module>
    from rest_framework.compat import template_render
ImportError: cannot import name template_render

According to the release notes, django-rest-framework removes Django 1.8 and 1.9 support (see commit). From the commit we see the 'template_render' function has been removed from rest_framework.compat.

Hi @abannerjee ,

What did you do with the first issue? I am facing the same issue and see if your resolution can help it.

wandrews4 commented 5 years ago

It would be really nice if there was a page which described which django package versions are compatible with which other django package versions. That might save us all a huge headache since it seems like a lot of people have this issue and it is not easy to find a resolution.

I my case it looks like my installed djangorestframework==3.9.4

is too new for my django-filter==1.1.0

So I downgraded the former to 3.5.4 and that seemed to help.