jayhale/vercel-django-example

Hi, can't deploy django on vercel as of 16 october 2022.

kirmola opened this issue · 4 comments

Hi, I have been getting this error Error: Cannot convert undefined or null to object

Can't seem to understand what's problem here, Python version 3.9, Django is also latest version of 4.1.2.

Here I've attached a log from vercel

[19:19:37.832] Retrieving list of deployment files...
[19:19:44.677] Downloading 5694 deployment files...
[19:24:32.401] Looking up build cache...
[19:24:32.657] Build Cache not found
[19:24:32.760] Running "vercel build"
[19:24:33.417] Vercel CLI 28.4.10-6fa5d8b
[19:24:34.130] WARN! Due to builds existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
[19:24:34.212] > Installing Builder: @ardnt/vercel-python-wsgi
[19:24:37.256] Starting build
[19:24:37.258] Build AMI version: Amazon Linux release 2 (Karoo)
[19:24:37.259] Lambda runtime: python3.9
[19:24:37.259] WSGI application: amancodes.wsgi.application
[19:24:37.259] ====> Selecting python version
[19:24:37.268] Found matching python (python3.9)
[19:24:37.269] ====> Installing pip
[19:24:37.269] ----> Installing pip
[19:24:37.346] Running "python3.9 get-pip.py"
[19:24:41.683] Collecting pip
[19:24:41.684] Downloading pip-22.3-py3-none-any.whl (2.1 MB)
[19:24:41.684] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 71.1 MB/s eta 0:00:00
[19:24:41.684] Collecting wheel
[19:24:41.684] Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
[19:24:41.685] Installing collected packages: wheel, pip
[19:24:41.685] Successfully installed pip-22.3 wheel-0.37.1
[19:24:41.685] ====> Downloading project
[19:24:45.179] ====> Installing handler
[19:24:45.180] ----> Installing python packages
[19:24:45.180] Running "pip install -t /tmp/5ba240c0 /vercel/path1/.vercel/builders/node_modules/@ardnt/vercel-python-wsgi"
[19:24:46.626] Processing ./.vercel/builders/node_modules/@ardnt/vercel-python-wsgi
[19:24:46.626] Preparing metadata (setup.py): started
[19:24:46.626] Preparing metadata (setup.py): finished with status 'done'
[19:24:46.627] Collecting Werkzeug==1.0.1
[19:24:46.627] Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
[19:24:46.627] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 298.6/298.6 kB 26.6 MB/s eta 0:00:00
[19:24:46.627] Building wheels for collected packages: vercel-python-wsgi
[19:24:46.628] Building wheel for vercel-python-wsgi (setup.py): started
[19:24:46.628] Building wheel for vercel-python-wsgi (setup.py): finished with status 'done'
[19:24:46.628] Created wheel for vercel-python-wsgi: filename=vercel_python_wsgi-1.1.1-py3-none-any.whl size=3891 sha256=d04be376bec741071725afc038b736e69c629bd4327dfe177b056cb5b6269b54
[19:24:46.628] Stored in directory: /vercel/.cache/pip/wheels/45/74/61/b48c4859feff53cd8f40a334dac76222c611094def81403007
[19:24:46.629] Installing collected packages: Werkzeug, vercel-python-wsgi
[19:24:46.629] Successfully installed Werkzeug-1.0.1 vercel-python-wsgi-1.1.1
[19:24:46.629] ====> Installing project requirements
[19:24:46.629] ----> Searching for "requirements.txt"
[19:24:46.629] Found global "requirements.txt"
[19:24:46.630] ----> Installing python packages
[19:24:46.630] Running "pip install -t /tmp/5ba240c0 -r /tmp/5ba240c0/requirements.txt"
[19:24:50.077] Collecting Django==4.1.2
[19:24:50.078] Downloading Django-4.1.2-py3-none-any.whl (8.1 MB)
[19:24:50.078] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.1/8.1 MB 79.5 MB/s eta 0:00:00
[19:24:50.078] Collecting asgiref<4,>=3.5.2
[19:24:50.078] Downloading asgiref-3.5.2-py3-none-any.whl (22 kB)
[19:24:50.079] Collecting sqlparse>=0.2.2
[19:24:50.079] Downloading sqlparse-0.4.3-py3-none-any.whl (42 kB)
[19:24:50.079] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.8/42.8 kB 8.2 MB/s eta 0:00:00
[19:24:50.079] Installing collected packages: sqlparse, asgiref, Django
[19:24:50.079] Successfully installed Django-4.1.2 asgiref-3.5.2 sqlparse-0.4.3
[19:24:50.080] ====> Preparing lambda bundle
[19:24:59.626] Done!
[19:24:59.628] Error: Cannot convert undefined or null to object

Please look into this matter

@amanrawat121 I suggest opening this as an issue for Vercel since the builder is completing successfully (it got to the final "Done!").

I modified this project and deployed. Seems fine now.. Thankyou for the response. HOWEVER I ran into another problem. It's not applying CSS. Can you help me in this case??? Here is console log.
domain.com/:26 Refused to apply style from 'http://domain.com/static/css/dist/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Solution for that here: https://stackoverflow.com/questions/35557129/css-not-loading-wrong-mime-type-django

FWIW, a better (i.e., lower cost) approach to static files on Vercel is to use their CDN functionality: https://jay-hale.medium.com/django-static-files-on-zeit-now-fef2c51215d4

Solved that too. Thanks for replying..