Monday, November 10, 2008

Day 1: Django - getting started - Django Tutorial

If you are on a linux system, check if you have python installed. Most probably it is.
shell> python
shell> .......
Download and install django and test it out

*********** Install Django ****************
wget http://www.djangoproject.com/download/1.0/tarball/
tar xvf Django-1.0.tar.gz
cd Django-1.0
sudo python setup.py install

*********** Test the install ***************
python
>>>> import django
>>>> django.VER
(1, 0, 'final')
>>>

************ Test to see if you have MySql installed ********************
1. Can you start and stop mysql on your system
sudo /etc/init.d/mysql start/stop

2. Initialize the grant tables
sudo mysql_install_db --user=mysql

3. Secure your mysql installation
mysql_secure_installation

4. log into mysql command line
mysql -u root -p

5. check users and set user passwords
select host,user from mysql.user;
set password 'xxxxxx'@'localhost'=password('dsfkjhdf');

6. check if you can log into mysql command line
mysql -u xxxxxx -p

****** create a new test site ****
1. django-admin.py startproject mysite
2. cd mysite
3. start django dev server
- python manage.py runserver
4. http://127.0.0.1:8000/

**** Installing mysqldb into python
python>>> import MySQLdb
---- if there is an error then install this

1. download libmysqldb python api from source forge
2. check if mysql_config is there in your system
3. if not do
apt-get install libmysqlclient15-dev
This will install the mysql_config tool.
4. python setup.py build
sudo python setup.py install

5. python>> import MySQLdb
-- no error successful



No comments: