Unable to deploy Django tutorial app to Render

I am new to programming and recently created my first two Django apps.

I followed this tutorial with the tutorial Django app to deploy it to Render.

The tutorial app runs locally fine via poetry run ./manage.py runserver

When I deploy at the end the database deploys but the webservice fails:

Jul 1 08:31:35 AM  ==> Checking out commit e64bd67cae1aa5f0a26b8957831ed0fc6b2adf2d in branch main
Jul 1 08:31:39 AM  ==> Using Node version 14.17.0 (default)
Jul 1 08:31:39 AM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Jul 1 08:31:39 AM  ==> Using Python version 3.7.10 (default)
Jul 1 08:31:39 AM  ==> Docs on specifying a Python version: https://render.com/docs/python-version
Jul 1 08:31:43 AM  ==> Using Poetry version  via 
Jul 1 08:31:43 AM  ==> Docs on specifying a Poetry version: https://render.com/docs/poetry-version
Jul 1 08:31:43 AM  ==> Running build command './build.sh'...
Jul 1 08:31:44 AM  
Jul 1 08:31:44 AM    RuntimeError
Jul 1 08:31:44 AM  
Jul 1 08:31:44 AM    The lock file is not compatible with the current version of Poetry.
Jul 1 08:31:44 AM    Upgrade Poetry to be able to read the lock file or, alternatively, regenerate the lock file with the `poetry lock` command.
Jul 1 08:31:44 AM  
Jul 1 08:31:44 AM    at /home/render/.python-poetry/venv/lib/python3.7/site-packages/poetry/packages/locker.py:482 in _get_lock_data
Jul 1 08:31:44 AM        478│                 "regenerate the lock file with the `poetry lock` command."
Jul 1 08:31:44 AM        479│             )
Jul 1 08:31:44 AM        480│         elif not lock_version_allowed:
Jul 1 08:31:44 AM        481│             raise RuntimeError(
Jul 1 08:31:44 AM      → 482│                 "The lock file is not compatible with the current version of Poetry.\n"
Jul 1 08:31:44 AM        483│                 "Upgrade Poetry to be able to read the lock file or, alternatively, "
Jul 1 08:31:44 AM        484│                 "regenerate the lock file with the `poetry lock` command."
Jul 1 08:31:44 AM        485│             )
Jul 1 08:31:44 AM        486│
Jul 1 08:31:44 AM  ==> Build failed 😞

I made sure to update poetry- still get the error.

If I change the python version in pyproject.toml to ^3.7 I get this error locally:

The current project's Python requirement (>=3.7,<4.0) is not compatible with some of the required packages Python requirement:
  - django requires Python >=3.8, so it will not be satisfied for Python >=3.7,<3.8

Because django (4.2.2) requires Python >=3.8
 and no versions of django match >4.2.2,<5.0.0, django is forbidden.
So, because cooper depends on django (^4.2.2), version solving failed.

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
    
    For django, a possible solution would be to set the `python` property to ">=3.8,<4.0"

Do I have to install an old version of Django? Or are there any tutorials on how to deploy my app without using Poetry?

Thank you.

Hi there,

The problem here will be that the version of Poetry you have locally will be newer than the default one we use in our native environment. You can fix this by setting the POETRY_VERSION to be the same version you have in your pyproject.toml (probably 1.5.1): https://render.com/docs/poetry-version.

Note you should also ensure that you are also setting the PYTHON_VERSION to be the same as you use in the pyprojetc.toml as well: https://render.com/docs/python-version.

Regards,

Keith
Render Support, UTC+10 :australia:

Thank you very much, Keith. I was able to get it deployed successfully. If any newbies are reading this later:

You specify the Environment variables online in the Render dashboard under the Environment tab. I spent a while trying to change these settings in my code.