"manage.py dumpdata" for dumping data to json file.
"manage.py loaddata" for loading data from json file.
"manage.py loaddata" for loading data from json file.
Typical Web Developer Blog. New Technologies, Mostly Step by Steps Guides to get it done quickly.
$./ manage.py dumpdata app.myModel1 app.myModel2 <relative_path_to_app>/fixtures/initial_data.json --indent 4
$ ./manage.py loaddata <relative_path_to_app>/fixtures/initial_data.json
$ sudo apt-get install python-setuptools $ sudo easy_install virtualenv $ sudo easy_install virtualenvwrapper $ mkdir ~/.virtualenvs
export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh
$ source .bashrc
$ mkvirtualenv -p python2.5 django
To use virtual environment named "django"
bracket contains the current virtual environment
$ workon django
To close virtual environment named "django"
$ (django)...:$ deactivate
$ workon django $ (django)...:$ add2virtualenv /home/user/additional_python_path $ (django)...:$ add2virtualenv Usage: add2virtualenv dir [dir ...] Existing paths: home/user/additional_python_path $ (django)...:$
$ mkvirtualenv django2 $ rmvirtualenv django2 $ workon django $ (django)...:$ deactivate $ workon django
Now The most important thing is "How to use virtualenv in
production ???"
For that you will need to add it's path to your PYTHONPATH.
/home/www/env/lib/python2.7/site-packages/
import os
my_virtualenv_path = "/home/www/my_project/env/lib/python2.7/site-packages/"
# Add it to your PYTHONPATH
os.path.append(my_virtualenv_path)
export PYTHONPATH:$PYTHONPATH:/home/www/my_project/env/lib/python2.7/site-packages/