问题描述
所有受支持的数据库后端均遵循Django 3.1
的{{1}}准则…
https://docs.djangoproject.com/en/3.1/releases/3.1/#jsonfield-for-all-supported-database-backends
JSONField
WARNINGS:
users.Search.input: (fields.W904) django.contrib.postgres.fields.JSONField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
HINT: Use django.db.models.JSONField instead.
…最终在from django.db import models
class ContactInfo(models.Model):
data = models.JSONField()
上出现错误:
Azure Web App
AttributeError: module 'django.db.models' has no attribute 'JSONField'
文件指定Django> = 3.1:
Requirements.txt
Django >= 3.1
控制台:
App Service Built
##[group]Run azure/appservice-build@v1
with:
platform: python
platform-version: 3.8
env:
pythonLocation: /opt/hostedtoolcache/Python/3.8.5/x64
...
No source directory was provided -- the root of the repository ('GITHUB_WORKSPACE' environment variable) will be built: '/github/workspace'
No output directory was provided
Platform provided: 'python'
Platform version provided: '3.8'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 131 100 131 0 0 262 0 --:--:-- --:--:-- --:--:-- 262
100 131 100 131 0 0 262 0 --:--:-- --:--:-- --:--:-- 262
Running command 'oryx build /github/workspace --platform python --platform-version 3.8 --enable-dynamic-install'
Build orchestrated by Microsoft Oryx,https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version : 0.2.20200312.2,Commit: d1cf6b4a89345b6a7d0dc25d0fbd67860862ee18,ReleaseTagName: 20200312.2
Build Operation ID: |xt2zaWLFTwY=.5ad82150_
Repository Commit : 75be0048ee098cbf42a032200e6ef6867a48b924
Source directory : /github/workspace
Destination directory: /github/workspace
Python Version: /opt/python/3.8.2/bin/python3
Python Virtual Environment: pythonenv3.8
Creating virtual environment ...
Activating virtual environment ...
Upgrading pip...
WARNING: The directory '/github/home/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo,you may want sudo's -H flag.
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo,you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/4e/5f/528232275f6509b1fff703c9280e58951a81abe24640905de621c9f81839/pip-20.2.3-py2.py3-none-any.whl (1.5MB)
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-20.2.3
Done in 2 sec(s).
Running pip install...
Collecting Django>=3.1
Downloading Django-3.1.1-py3-none-any.whl (7.8 MB)
Collecting psycopg2-binary
Downloading psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl (3.0 MB)
...
Building wheels for collected packages: isort
Building wheel for isort (PEP 517): started
Building wheel for isort (PEP 517): finished with status 'done'
Created wheel for isort: filename=isort-5.5.2-py3-none-any.whl size=96676 sha256=51272461d0c723dd22ff1a2f9eeb14b85dcb526eb89afaeaa56a444601358acd
Stored in directory: /tmp/pip-ephem-wheel-cache-2s_h_h49/wheels/1e/39/35/2df4c05d92066f85f187318ea94000afe7a684a28361f823cb
Successfully built isort
...
Successfully installed Django-3.1.1 PyJWT-1.7.1 apscheduler-3.6.3 asgiref-3.2.10 astroid-2.4.2 azure-common-1.1.25 azure-core-1.8.1 azure-identity-1.0.1 azure-keyvault-secrets-4.0.0 cachetools-4.1.1 certifi-2020.6.20 cffi-1.14.2 chardet-3.0.4 click-7.1.2 cryptography-3.1 defusedxml-0.6.0 diff-match-patch-20200713 django-apscheduler-0.3.0 django-braces-1.14.0 django-cas-ng-4.1.1 django-crispy-forms-1.9.2 django-debug-toolbar-2.2 django-import-export-2.3.0 django-money-1.1 django-pandas-0.6.2 et-xmlfile-1.0.1 google-api-core-1.22.2 google-auth-1.21.1 googleapis-common-protos-1.52.0 googletrans-3.0.0 h11-0.9.0 h2-3.2.0 hpack-3.0.0 hstspreload-2020.9.9 httpcore-0.9.1 httpx-0.13.3 hyperframe-5.2.0 idna-2.10 isodate-0.6.0 isort-5.5.2 jdcal-1.4.1 joblib-0.16.0 lazy-object-proxy-1.4.3 lxml-4.5.2 markuppy-1.14 mccabe-0.6.1 msal-1.5.0 msal-extensions-0.1.3 msrest-0.6.19 nltk-3.5 numpy-1.19.2 oauthlib-3.1.0 odfpy-1.4.1 opencensus-0.7.10 opencensus-context-0.1.1 opencensus-ext-azure-1.0.4 opencensus-ext-django-0.7.2 opencensus-ext-logging-0.1.0 opencensus-ext-postgresql-0.1.2 openpyxl-3.0.5 pandas-1.1.2 portalocker-1.7.1 protobuf-3.13.0 psutil-5.7.2 psycopg2-binary-2.8.6 py-moneyed-0.8.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.20 pylint-2.6.0 python-cas-1.5.0 python-dateutil-2.8.1 python-docx-0.8.10 pytz-2020.1 pyyaml-5.3.1 rake-nltk-1.0.4 regex-2020.7.14 requests-2.24.0 requests-oauthlib-1.3.0 rfc3986-1.4.0 rsa-4.6 scikit-learn-0.23.2 scipy-1.5.2 six-1.15.0 sniffio-1.1.0 sqlparse-0.3.1 tablib-2.0.0 threadpoolctl-2.1.0 toml-0.10.1 tqdm-4.49.0 tzlocal-2.1 urllib3-1.25.10 whitenoise-5.2.0 wrapt-1.12.1 xlrd-1.2.0 xlwt-1.3.0
Done running pip install.
Content in source directory is a Django app
Running collectstatic ...
248 static files copied to '/github/workspace/staticfiles',614 post-processed.
'collectstatic' exited with exit code .
Done in 3 sec(s).
Removing existing manifest file
Creating a manifest file...
Manifest file created.
Done in 65 sec(s).
控制台:
Oryx
解决方法
当我忘记更新我的requirements.txt文件以使用Django> = 3.1.0,
,尝试在服务器上运行应用程序时遇到相同的问题。 在本地(ubuntu-20.04)适用于
- Python == 3.6.7
- Django == 3.1.3
但是在具有相同版本的django和python的服务器(debian-stretch)上,我遇到了相同的问题! 我尝试过django == 3.0,问题仍然存在
Nov 05...gunicorn[19911]: created_group = models.JSONField(default=default_created_group)
Nov 05...gunicorn[19911]: AttributeError: module 'django.db.models' has no attribute 'JSONField'
应用新的models JSONField recommendation的唯一方法是使用Django 3.1
,我看到这个错误是因为我在我的项目中使用了 pipenv
并且在运行应用程序之前忘记运行 pipenv shell
命令。
实际上,我们的 import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as axes3d
dfsample = pd.DataFrame(np.random.randint(1,10,size=(16,16)))
h,w = dfsample.shape #get the shape of the data
z = dfsample
theta = np.linspace(0,2 * np.pi,w) # radians from 0 to 2pi
THETA,Z = np.meshgrid(theta,z)
r = np.sqrt(0.6)
X = r * np.cos(THETA)
Y = r * np.sin(THETA)
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(1,1,projection='3d')
cmap = plt.get_cmap('YlOrRd')
plot = ax.plot_surface(X,Y,Z,rstride=1,cstride=1,facecolors=cmap(Z),linewidth=0,antialiased=True,alpha=0.75)
plt.show()
文件夹包含错误的文件和文件夹,这些文件可以追溯到以前从未清理过的 git push 中,其中包括未删除的旧安装的 wwwroot
。
使用 FTP Django v3.0.5
访问 wwwroot
并删除其所有内容解决了这个问题。