Python & Poetry - Version Mismatch and Django Getting Started Documentation Omission - "Can't Change Python Version of Django Project"

Hi all,

Began following: Getting Started with Django on Render | Render

Discovered, at time of writing, Python 3.7 is used by default with Render and Poetry.

Wanted to upgrade to newer Python version. Followed linked instructions at the bottom of page - Specifying a Python Version | Render - to do that.

Deploy failed. Reason is that although Python was updated, Poetry will still use its original version (3.7). Users need to provide an argument that essentially tells Poetry to ignore that version and use the one specified in the .toml instead. This is missing from the documentation.

Folks need to add poetry lock --no-update to the build.sh file before the poetry install line when upgrading Python Versions.

Hope this helps, and finds its way to someone so that the docs can be updated.

2 Likes

Ran into the same issue shortly after OP posted their solution. Would like to see this added to the Getting Started docs as well.

poetry lock --no-update before poetry install also resolved this for me

In my case, I was trying to use python 3.10.8 for my project, but the specific failure was in the poetry solver stage, and the path for the solver being used showed python 3.7, which is what tipped me off

FWIW I’m using Flask, so if the action here is “the Django tutorial is updated” that might not have helped me. The Flask docs don’t use poetry but have a generic “feel free to use poetry instead!” comment.

The “real” fix needed here should be that the poetry install as a build command “just works” in terms of respecting the PYTHON_VERSION env var, which is, according to the docs, the proper way to specify a Python version for your project: