Django 3.1+: (fields.E180) SQLite does not support JSONFields

Udi*_*Udi 5 sqlite django jsonfield django-3.1

I have created a Django project with the new JSONField announced in Django 3.1, which supports all databases.

I have successfully used this field on a linux machine, but running python manage.py migrate with the same project on Windows fails with the following message:

(fields.E180) SQLite does not support JSONFields.
Run Code Online (Sandbox Code Playgroud)

The same versions of Python and Django are used in both PCs.

Udi*_*Udi 12

For using JSONField with Django 3.1+ and sqlite, the JSON1 sqlite extension must be installed.

To enable JSON1 on sqlite follow the instructions on Django's wiki: https://code.djangoproject.com/wiki/JSON1Extension.

Instructions for Windows:

  • Check your python installation - is it 32bit or 64bit? run: python -c "import platform;print(platform.architecture()[0])"
  • Download the precompiled DLL that matches your Python installation (32-bit or 64-bit).
  • 找到您的 Python 安装。默认情况下,它应该在 中%localappdata%\Programs\Python\PythonXX,其中 XX 是 Python 版本。例如,它位于C:\Users\<username>\AppData\Local\Programs\Python\Python37. 如果您将 Python 安装目录添加到 PATH 环境变量中,则可以where python在命令提示符下运行该命令来定位它。在 Python 安装中输入 DLLs 目录。
  • sqlite3.dllDLLs目录内重命名(或删除)。
  • sqlite3.dll从下载的 DLL 存档中提取并将其放入DLLs目录中。
  • 现在,JSON1 扩展应该可以在 Python 和 Django 中使用了。