{"id":89,"date":"2014-11-24T17:13:00","date_gmt":"2014-11-24T11:43:00","guid":{"rendered":"http:\/\/bhuvan.wordpress.com\/?p=89"},"modified":"2014-11-24T17:13:00","modified_gmt":"2014-11-24T11:43:00","slug":"setup-of-django-virtualenv-and-dependencies-using-pip","status":"publish","type":"post","link":"https:\/\/www.bhuvankrishna.in\/blog\/2014\/11\/24\/setup-of-django-virtualenv-and-dependencies-using-pip\/","title":{"rendered":"Setup of django, virtualenv and dependencies using pip"},"content":{"rendered":"<p>Recently I started working on a django project which is exciting at the same time challenging. I thought its good time to document some of the steps to deploy the project and these are the steps to follow.<\/p>\n<h4>System requirements<\/h4>\n<p>In a typical debian system run the following commands to get required packages before we start the setup.<br \/>\n<code>#apt-get install python-pip python-virtualenv libpq-dev<\/code><\/p>\n<h4>Setup of virtualenv<\/h4>\n<p>To run a virtualenv follow these steps.<br \/>\n1. select a directory to install custom python.<br \/>\n<code>virtualenv \/home\/user\/virtual<\/code><br \/>\n2. Run the following command to start the environment.<br \/>\n<code> source \/home\/user\/virtual\/bin\/activate<\/code><br \/>\n3. To deactivate<br \/>\n<code>deactivate<\/code><\/p>\n<p>Courtesy: http:\/\/docs.python-guide.org\/en\/latest\/dev\/virtualenvs\/<\/p>\n<h4>Install specific version of django<\/h4>\n<p>To install a specific version of django<br \/>\n<code>pip install django=1.6.2<\/code><br \/>\nThis is the working version of django. 1.6 is not working.<\/p>\n<h4>Install dependencies<\/h4>\n<p>1. Install the dependencies of pflat<br \/>\n<code> pip install south django-chosen django-datetime-widget psycopg2<\/code><\/p>\n<h4>Additional tweaks<\/h4>\n<p>Create a db and user. follow this link https:\/\/bhuvan.wordpress.com\/2014\/11\/20\/adding-postgresql-user-and-db-quick-steps\/<\/p>\n<p>Running python manage.py syncdb will show the error<br \/>\n<code>FATAL: Peer authentication failed for user \"tom\"<\/code><br \/>\nto fix the error edit the file \/etc\/postgresql\/9.4\/main\/pg_hba.conf. Make sure you are editing the right postgresql version file. Go down and change the line<\/p>\n<pre>local   all             postgres                                peer<\/pre>\n<p>to<\/p>\n<pre>local   all             postgres                                md5<\/pre>\n<p>After editing the file restart postgresql.<\/p>\n<h4>Sync DB and migrate<\/h4>\n<p>Run these 2 commands to sync the database and migrate data if any from root of the project.<br \/>\n<code>python manage.py syncdb<\/code><br \/>\n<code>python manage.py migrate<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I started working on a django project which is exciting at the same time challenging. I thought its good time to document some of the steps to deploy the project and these are the steps to follow. System requirements In a typical debian system run the following commands to get required packages before we\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.bhuvankrishna.in\/blog\/2014\/11\/24\/setup-of-django-virtualenv-and-dependencies-using-pip\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":0,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}