10. Creating test project on virtualenv
Now, we want to install on the virtual environment.
(DjangoVirtualenv)k@HP-Notebook:~/Django/DjangoVirtualenv$ easy_install Django
Finally, Django has been installed. We can check inside the bin directory:
$ ls activate activate.fish django-admin.py easy_install-2.7 pip2 python python2.7 activate.csh activate_this.py easy_install pip pip2.7 python2
The django-admin.py will be used to create our Django project.
Let's first look at what subcommands we can use with django-admin.py:
$ django-admin.py Usage: django-admin.py subcommand [options] [args] ... Available subcommands: [django] check cleanup compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages runfcgi runserver shell sql sqlall sqlclear sqlcustom sqldropindexes sqlflush sqlindexes sqlinitialdata sqlsequencereset startapp startproject syncdb test testserver validate
We'll use the startproject subcommand to create our project:
$ django-admin.py startproject DjangoTestProject $ ls bin DjangoTestProject include lib local
We can see what are in the DjangoTestProject directory.
The manage.py will be used to run the server as shown in the next section.
Let's run the Django powered test web server.
$ cd DjangoTestProject $ ~/Django/DjangoVirtualenv/DjangoTestProject$ python manage.py runserverValidating models... 0 errors found ... Django version 1.6.2, using settings 'DjangoTestProject.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
Now we want to switch back to real from virtual environment. We do it by deactivating it.
(DjangoVirtualenv)k@HP-Notebook:~/Django/DjangoVirtualenv/DjangoTestProject$ deactivate k@HP-Notebook:~/Django/DjangoVirtualenv/DjangoTestProject$
Now we're no longer under virtualenv. Note that we do not have virtual environment name, (DjangoVirtualenv), in the last prompt.
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization