26👍
Your version of django-allauth
has the incorrect import for FieldDoesNotExist
. The correct import is:
from django.core.exceptions import FieldDoesNotExist
The import from django.db.models
presumably worked in older versions of Django.
The import was fixed in django-allauth
in version 0.41.0. If you update django-allauth
in your requirements.txt
or pipenv it should fix the problem.
21👍
In my case, Django version 3.1.3
conflicted with django-filter 2.0.0
.
Similar error message. But the last lines of error said that it was graphene-django
. However, in the middle, it says django-filter
. When I looked into the django-filter
source file, there was a wrong import of FieldDoesNotExist
. When I upgrade django-filter
to version 2.4.0
, problem solved.
- [Django]-How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku?
- [Django]-Django manage.py : Is it possible to pass command line argument (for unit testing)
- [Django]-Using Django settings in templates
2👍
In OP’s case it was django-allauth, in my case django-filter.
Check the last line in error log that shows the file in which from django.db.models import FieldDoesNotExist, FileField
is imported and try upgrading that package.
In OP’s case the error log line was this:
File "/usr/local/lib/python3.7/site-packages/allauth/utils.py"...
- [Django]-Defining Constants in Django
- [Django]-Use Crispy form with ModelForm
- [Django]-Generating file to download with Django
1👍
As I can see you have version 3.0.8
.
But for me, it helped when I changed requirements.txt
from Django>=3.0.6
(used latest 3.1 Docker image) to Django==3.0.6
as I was using the latest 3.1 version where it seems to be an issue with compatibility on 3rd party packages.
- [Django]-Django – view sql query without publishing migrations
- [Django]-Foreignkey (user) in models
- [Django]-How can I pass my context variables to a javascript file in Django?
1👍
My error log showed that the error was coming from the rest_framework app
(File "/home/Username_here/restapi-basics/lib/python3.8/site-packages/
rest_framework/serializers.py", line 25, in ). But I couldn’t upgrade it (as specified in the solutions above) since it was just an app I had added to my Django project.
What worked for me was upgrading all the packages in my virtual environment using pip. Here’s the command I used:
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
- [Django]-How can I exclude South migrations from coverage reports using coverage.py
- [Django]-NumPy array is not JSON serializable
- [Django]-Migrating existing auth.User data to new Django 1.5 custom user model?
0👍
I faced a similar issue cannot import name 'FieldDoesNotExist' from 'django.db.models.fields'
and this time issue was with mismatch djangorestframework
with the base Django version
I was using djangorestframework
3.7.3
with Django
3.2.15
, which was later resolved by upgrading djangorestframework
3.11.0
using
pip install djangorestframework==3.11.0
So in case anyone is facing such an issue, it’s better to check the various django component compatibility
- [Django]-Can I set a specific default time for a Django datetime field?
- [Django]-Django – query filter on manytomany is empty
- [Django]-How to get OR permissions instead of AND in REST framework