Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'six' #326

Open
ibayeux opened this issue Jan 9, 2020 · 18 comments
Open

ImportError: cannot import name 'six' #326

ibayeux opened this issue Jan 9, 2020 · 18 comments

Comments

@ibayeux
Copy link

ibayeux commented Jan 9, 2020

A specified in Django 3.0 release note, django.utils.six is removed. In case you need it, it is advised to use pypi packages instead.
can you update?

@poojansmobio
Copy link

poojansmobio commented May 7, 2020

"pip install --upgrade djangorestframework"
update the Django rest framework to the latest will resolve the issue.

@glothos
Copy link

glothos commented May 7, 2020

Same happening here, upgrading djangorestframework didn't help

@poojansmobio
Copy link

Same happening here, upgrading djangorestframework didn't help

Which Django version you are using currently?

@YukinoHayakawa
Copy link

Updating to djangorestframework-filters==1.0.0.dev0 resolved my same issue.

@eliezerp3
Copy link

eliezerp3 commented Jun 2, 2020

Updating to djangorestframework-filters==1.0.0.dev0 resolved my same issue.

Having the same import problem. I tried your solution and it worked but do u know how stable it is for production?

@YukinoHayakawa
Copy link

Updating to djangorestframework-filters==1.0.0.dev0 resolved my same issue.

Having the same import problem. I tried your solution and it worked but do u know how stable it is for production?

Unfortunately, I have no clear idea about that. I'm writing for tools for my personal use only. However, I'd suppose that a production-ready version won't be released with a dev label on it :)

@oguzhancelikarslan
Copy link

getting this error after placing configuration dict.

'DEFAULT_FILTER_BACKENDS': (
'rest_framework_filters.backends.RestFrameworkFilterBackend',
),

Django version: 3.0.7
ImportError: Could not import 'rest_framework_filters.backends.RestFrameworkFilterBackend' for API setting 'DEFAULT_FILTER_BACKENDS'. ImportError: cannot import name 'six' from 'django.utils'

@gmuj
Copy link

gmuj commented Jul 31, 2020

I solved this by installing latest https://github.com/carltongibson/django-filter
Since most of the stuff used by this library is merged back into django-filter I didn't have any problems using it. You just need to follow the installation step and change package imports paths.

Note that you need to uninstall this package before as it relies on an older version and you get this error
ERROR: djangorestframework-filters 0.11.1 has requirement django-filter~=1.1, but you'll have django-filter 2.3.0 which is incompatible.

@petrosschilling
Copy link

Hey @poojansmobio do you have any updates on this? I'm happy to collaborate with you to solve this issue!

@poojansmobio
Copy link

Hey, @petrosschilling updating the django-rest-framework and installing pip install six worked for me.

@petrosschilling
Copy link

petrosschilling commented Oct 21, 2020

Hey, @petrosschilling updating the django-rest-framework and installing pip install six worked for me.

I did it but I get a dependency issue:

djangorestframework-jsonapi 3.2.0 requires djangorestframework<3.12,>=3.10, but you'll have djangorestframework 3.12.1 which is incompatible.

So basically I need to wait for a new version of djangorestframework-jsonapi before I can do this update.

@poojansmobio
Copy link

Hey, @petrosschilling updating the django-rest-framework and installing pip install six worked for me.

I did it but I get a dependency issue:

djangorestframework-jsonapi 3.2.0 requires djangorestframework<3.12,>=3.10, but you'll have djangorestframework 3.12.1 which is incompatible.

So basically I need to wait for a new version of djangorestframework-jsonapi before I can do this update.

In your case try downgrading it to djangorestframework==3.11.0 and check.

@petrosschilling
Copy link

petrosschilling commented Oct 21, 2020

I'm using JRF 3.11.1. Which save me from the conflicts.

The problem lies in the filterset.py file.

I checked the tag of version 0.11.1 and it still uses six.

filterset.py

from __future__ import absolute_import
from __future__ import unicode_literals

from collections import OrderedDict
import copy

from django.db.models.constants import LOOKUP_SEP
from django.utils import six

from django_filters import filterset, rest_framework
from django_filters.utils import get_model_field

from . import filters
from . import utils

@poojansmobio
Copy link

I'm using JRF 3.11.1. Which save me from the conflicts.

The problem lies in the filterset.py file.

I checked the tag of version 0.11.1 and it still uses six.

filterset.py

from __future__ import absolute_import
from __future__ import unicode_literals

from collections import OrderedDict
import copy

from django.db.models.constants import LOOKUP_SEP
from django.utils import six

from django_filters import filterset, rest_framework
from django_filters.utils import get_model_field

from . import filters
from . import utils

Replace
from django.utils import six
To
import six

@petrosschilling
Copy link

petrosschilling commented Oct 21, 2020

Replace
from django.utils import six
To
import six

Well that is not feasible, because in case i need to re-create my environment I will have to remember to change that import. Not only me but all other devs as well.

What I've done (for now) is to use the latest dev version (djangorestframework-filters==1.0.0.dev2) which will do for the time being.

The RelatedFilter is pretty good by the way. It is exactly what I was looking for. It doesn't pick up the override of the lookup_expr though:

class ClientAccountFilterSet(BaseFilterSet):
    individuals = RelatedMultipleFilter(IndividualFilterSet, queryset=Individual.objects.all())

class IndividualFilterSet(BaseFilterSet):
    first_name = CharFilter(lookup_expr="icontains")

    class Meta:
        model = Individual
        fields = [
            "first_name",
        ]

It still filter with exact not with icontains.

But that is another issue.

Thanks for your time and help!
I might look into fixing this problem :)

@sinjihn-4th-valley
Copy link

sinjihn-4th-valley commented Jan 28, 2021

ModuleNotFoundError: No module named 'rest_framework_filtersstorages'

After trying

Updating to djangorestframework-filters==1.0.0.dev0 resolved my same issue.

@ashish141199
Copy link

ModuleNotFoundError: No module named 'rest_framework_filtersstorages'

After trying

Updating to djangorestframework-filters==1.0.0.dev0 resolved my same issue.

You might have missed a comma (,) after 'rest_framework_filter'

@hwalinga
Copy link

@ashish141199 The latest pre-release is 1.0.0.dev2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests