Friday, August 8, 2014

Django Related setup


Ubuntu comes with default python 2.7

install pip using sudo apt-get install python-pip 


Create a virtualenv so that all you various versions of installations are localized to just that env.

For example : If you are working on 2 applications , one requiring 1.4 DJango and another one 1.6 Django
You do not want both of them to overlap. This is where virtualenv will come in handy.

use linux command sudo pip install virtualenv

Once you have the virtual env

create a virtual env  $virtualenv renv (renv can be any name you want)

before activating the virtual env set these variables up

edit your activate file inside renv/bin/ to include these exports
export DJANGO_SETTINGS_MODULE=settings
 export DJANGO_ENVIRONMENT=local

activate this virtualenv by issuing the command $ cd renv

followed by $ source/bin/activate  

This would save you the time in setting these values every time.

Once inside the virtual env and activated start installing the required software by using PIP.

Get the requirements.txt for your project.

But before installing the packages install psycopg libraries to avoid failure.
sudo apt-get install libpq-dev python-dev

now run

$ sudo pip install -r requirements.txt

This will install all the softwares listed in the file. At this point all of these softwares are only visible if the virtualenv (in this case renv) is activated.

You should have a clean build. If not document the errors here so that future Bolgians can seek help.

In order to install psycopg libraries use this
http://stackoverflow.com/questions/5420789/how-to-install-psycopg2-with-pip-on-python


Once you have the code from GIT and have installed all the python dependencies run the below commands to set up the data needed for logging in


  1. python manage.py syncdb
  2. create admin user so that you can log into admin screen
  3. python manage.py migrate takeaway
  4. python manage.py migrate notifications
  5. go to this link localhost:8000/takeaway/initload to load data
  6. now login with ravi/abc123 or atluri/abc123 to enter the app
  7. have fun


No comments:

Post a Comment