Installation of Virtual Environment for Django

Is it necessary every time after shutdown I need to create virtual environment for the Django project I'm doing. correct me in Some ways possible .

When you create a virtual environment you can activate it (go inside to Venv), after finishing your job or want to change virtual environments you can deactivate it (exit from it ), and you can activate it again every time you want . You dont have to create it agian. Just activate it.

look at this example

$ mkdir client-old
$ cd client-old
$ python3 -m venv venv --prompt="client-old"
$ source venv/bin/activate
(client-old) $ python -m pip install django==2.2.26
(client-old) $ python -m pip list
Package    Version
---------- -------
Django     2.2.26
pip        22.0.4
pytz       2022.1
setuptools 58.1.0
sqlparse   0.4.2
(client-old) $ deactivate

$ cd ..
$ mkdir client-new
$ cd client-new
$ python3 -m venv venv --prompt="client-new"
$ source venv/bin/activate
(client-new) $ python -m pip install django==4.0.3
(client-new) $ python -m pip list
Package    Version
---------- -------
asgiref    3.5.0
Django     4.0.3
pip        22.0.4
setuptools 58.1.0
sqlparse   0.4.2
(client-new) $ deactivate
$ cd client-old
$ python3 -m venv venv --prompt="client-old"
$ source venv/bin/activate
(client-old) $  #this activate again good luck

Source

Useful link

Back to Top