How to add / import a Django project in virtualenv?

I'm just starting to use virtualenv , and I want to import an old Django project into a new virtualenv . What is the best way to do this?

I tried to just copy my old Django project inside the new virtualenv , but Django compiles with the old Path project, not the one inside virtualenv .

+6
source share
1 answer

He should work immediately. Just copy / paste the Django application folder into the virtualenv environment, and when python manage.py runserver in this folder, it should use virtualenv own python binary with its site-packages path.

Check your paths inside your Django app. Do not arrange them, you should do something like this:

 import os settings_dir = os.path.dirname(__file__) PROJECT_ROOT = os.path.abspath(os.path.dirname(settings_dir)) 

and then connect PROJECT_ROOT with everything you want to declare as a path inside your settings.py

Hope this helps!

+1
source

Source: https://habr.com/ru/post/956979/


All Articles