I use ubuntu in AWS for deploy a django project. when I run python3 manage.py runserver
, this error occurs:
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ubuntu/django/opensource-job-portal/peeldb/models.py", line 13, in <module>
from django.db.models import Q, Count, F, JSONField
ImportError: cannot import name 'JSONField'
I use Django 3.0.11.
How to solve my problem?
According to the docs , this was introduced in Django 3.1. So you need to use Django version at least 3.1 to import JSONField like this.
If you're using Postgres, you can do this with Django 3.0 and earlier:
from django.contrib.postgres.fields import JSONField
ImportError: cannot import name 'urlresolvers'
This was deprecated in django 1.9 Use django.urls instead if you want to use reverse.
from django.urls import reverse
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.