Saturday, October 30, 2021

[SOLVED] How to start a new Django project using poetry?

Issue

How to start a new Django project using poetry?

With virtualenv it is simple:

virtualenv -p python3 env_name --no-site-packages
source env_name/bin/activate
pip install django
django-admin.py startproject demo
pip freeze > requirements.txt

What will be equivalent to this using Poetry?


Solution

Create a new project folder and step in:

$ mkdir djangodemo
$ cd djangodemo

Create a basic pyproject.toml with django as dependency:

$ poetry init --no-interaction --dependency django

Create venv with all dependencies needed:

$ poetry install

Init your demo-project

$ poetry run django-admin.py startproject djangodemo


Answered By - finswimmer