Table of Contents
|
Setup a Django test project in the CSIE ~/ (home) Directory (without root access)
1. Ensure Python 2.5 is in the PATH (python 2.5 includes sqlite3 and pysqlite)
1.1 Set PATH
b96123@linux11 [~/bin] vi ~/.shrc
add the following export:
# Ensure python 2.5 is used (pysqlite and sqlite3) export PATH=/home/student/96/b96123/bin:$PATH
1.2 Create symlink (so that python2.5 is used)
b96123@linux11 [~/] cd ~ b96123@linux11 [~/] mkdir bin b96123@linux11 [~/] ln -s /usr/bin/python2.5 bin/python
1.3 Source the script
b96123@linux11 [~/] . ~/.shrc
2. Install Django
Good tutorial:
http://www2.jeffcroft.com/blog/2006/may/11/django-dreamhost/
Setup a Django test project (aka hello world web application) on Windows
1. Install Python 2.5
Note: Don't forget to set the PATH environment variable
1.0: Download it from: http://www.python.org/download/releases/2.5/
1.1: Install it
1.2: Update PATH settings: System -> Advanced -> Environment Settings
1.3: Update the system PATH variable
Put the following information
C:\apps\Python25\Scripts;C:\apps\Python25;
in front of the existing PATH environment variable.
2. Install pysqlite
Note: Download the appropriate release from:
http://initd.org/pub/software/pysqlite/releases/2.4/2.4.0/
Example (for Python 2.5):
http://initd.org/pub/software/pysqlite/releases/2.4/2.4.0/pysqlite-2.4.0.win32-py2.5.exe
3. Download the DJango Tarball
Direct Download Link:
http://www.djangoproject.com/download/0.96.1/tarball/
4. Untar the tarball and install django
Preliminary check:
$ which python
C:\apps>which python
/cygdrive/c/apps/Python25/python
If /usr/lib/python is used check your environment settings and don't continue!
$ mkdir c:\apps $ cd c:\apps $ cp [DOWNLOAD_FOLDER]/Django-0.96.1.tar.gz . $ tar xzvf Django-0.96.1.tar.gz $ cd Django-0.96.1 $ python setup.py install
Note: If you don't have the tar utility on your system install cygwin
http://www.cygwin.com/. Direct Download: http://www.cygwin.com/setup.exe
Note 2: You can open the tarball with WinZip though (…but cygwin will be useful anyway
sooner or later)
Note 3: Path when using cygwin:
Ex: /cygdrive/c/apps/django/Django-0.96.1$ python setup.py install
5. Check if installation was successful
Where are we?
You should be in the directory: C:\apps\django\Django-0.96.1>
Create a test project
$ django-admin.py startproject testproject $ cd testproject $ python manage.py runserver
Browse to http://localhost:8000 and you should see a message like:
It worked!
Congratulations on your first Django-powered page.
6. Configure database settings
Note: If you are interested in details, check out -> http://www.djangoproject.com/documentation/tutorial01/
It's time to edit the database settings (we are using the sqlite db). Edit settings.py.
Change the following settings:
Open new shell (cmd.exe or cygwin)
$ cd C:\apps\django\Django-0.96.1\testproject $ notepad settings.py
DATABASE_ENGINE = 'sqlite3' # ... DATABASE_NAME = 'testdb.db' # ...
Sync the database (creates the database tables)
Quote:
"The syncdb command looks at the INSTALLED_APPS setting and creates any necessary
database tables according to the database settings in your settings.py file."
- Source: http://www.djangoproject.com/documentation/tutorial01/
$ python manage.py syncdb
Output:
Creating table auth_message
Creating table auth_groups
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username: admin
….
7. Environment setup is completed - Congratulations! :)
8. Setup your first 'hello world' web application
Follow the instructions @http://www.djangoproject.com/documentation/0.96/tutorial01/
Section: Creating models
Note: the sample project in the tutorial is called mysite, whereas our project is called testproject.
!!! make sure that you replace mysite with testproject whenever you edit any configuration files !!!
Note 2: It's important that you use the 0.96 tutorial since we use the 0.96 release and
not the development release. For example the model field class attribute maxlength is used
in 0.96 (what we are using) but is called max_length in the current development release.
So if you encounter an error like:
TypeError: init() got an unexpected keyword argument 'max_length'
after executing: C:\apps\django\Django-0.96.1\testproject>python manage.py sql polls
you might read the wrong tutorial.
Misc Stuff
to be done later..
Step X. Install Subversion
tortoise svn
http://subversion.tigris.org/
Other tutorials
Install Django on Win32
http://ymasuda.jp/python/django/minimal_win32_django_installation_e.html
Django Djumpstart: Build a To-do List in 30 Minutes
http://www.sitepoint.com/article/build-to-do-list-30-minutes/2
Build to do list in 30 minutes
http://www.sitepoint.com/article/build-to-do-list-30-minutes
Writing your first Django App
http://www.djangoproject.com/documentation/tutorial01/
Misc Info
Builtin Web Server
Django development server, a lightweight Web server written purely in
Python. We’ve included this with Django so you can develop things rapidly,
without having to deal with configuring a production server
— such as Apache — until you’re ready for production.
Runserver
./manage.py runserver 0.0.0.0:8000
What this does is runs the server attaching to the IP address of
your machine rather than 127.0.0.1. This allows you to go to another
computer on your network and enter the IP address of your machine as the URL
(eg: http://192.168.1.2:8000/) and pull up the site.
This is great if you're developing on a Mac, say, and want to test in IE6 or IE7.
FastCGI, SCGI, and Apache: Background and Future
http://www.vmunix.com/mark/blog/archives/2006/01/02/fastcgi-scgi-and-apache-background-and-future