I 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 is compiling with the old Path project and not with the one inside of the virtualenv
.
Open myproject as your project and then go to PyCharm -> Preferences... -> Django, Enable Django Support and then choose your Django project root, settings file and manage script. Save this answer.
It should work immediately. Just copy/paste the Django app folder into the virtualenv
environment and when you issue python manage.py runserver
on that folder, it should use virtualenv
's own python
binary with it's site-packages
path.
Checkout your paths inside your Django app. Don't hardwire 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 concatenate PROJECT_ROOT
with everything you want to declare as path inside your settings.py
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With