Baabtra django framework installation and sample project using aptana

Preview:

DESCRIPTION

This explains the following questions. 1. How to install Aptana in Windows 8 64 bit os? 2. How to install Python in Windows 8 64 bit os? 3. How to install Django in Windows 8 64 bit os? 4. How to run a sample application in Django in Windows 8 64 bit os? This will be useful for candidates who are learning Django framework.

Citation preview

• This PPT explains three things1. How to install Django framework on

Windows 8 64 bit OS?2. How to configure aptana Studio for using

Django framework?3. How to create a simple sample application

using Django framework in Aptana Studio?

How to install Django framework on Windows 8 64 bit OS with Aptana?

Haris NPharis@baabtra.comwww.facebook.com/haris.np9twitter.com/np_harisin.linkedin.com/in/harisnp

Steps

• Install Python 2.7• Install MySQL for Python (You need to install

the corresponding driver for your DBMS)• Install Django• Install Aptana

Step 1: Python installation

• Down load Python from the following link– http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi

(Please note that you should not install 64 bit version of the Python. If you install, you will get an error that MySQL is not a valid Win32 application). The idea is if you are using Python and MySQL, then you should use both Python and MySQL 32 bit. The 32 bit version of python will run in 64 bit operating system.

– http://python.org/ftp/python/3.3.2/python-3.3.2.amd64.msi (If you are using MySQL database, you can not use python 3.3.2 as there is no MySQL driver released for Python 3.3.2)

– After installation, add the path of Python to the environment variables as shown in the screen shot

• Python 2.7 and Python 3.3

• In order to verify that Python is installed properly, type python in the command prompt. As we have added to the environment path, python command should execute from any folder in the computer

Step 2: MySQL-Python-1.2.3 install

• Download the mysql driver for python from the following link

http://www.codegood.com/download/10/File Name : MySQL-python-1.2.3.win32-py2.7.exe Or MySQL-python-1.2.4.win32-py2.7

• Double click on the EXE file

Now you might get this error

• Python version 2.7 required, which was not found in the registry – Windows 8 64 Bit OS

Reason

• Setup is looking for the Python installation registry value InstallPath inHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath. Notice the Wow6432Node, which is a registry compatibility layer used for 32-bit apps in Windows 8 64-bit

What to do?

• Open Run (Window + R)• Type regedit

• Go to Wow6432Node as shown

• Click Edit New Key

• Create Folder Python

• Repeat the same steps by choosing the folder Python

• Create the folder structure• Python PythonCore 2.7 InstallPath

InstallGroup

• Double click on (Default) as shown

• Copy paste the value from the registry HKLM Software Python PythonCore 2.7 InstallPath

• Double click on InstallGroup • Change to the value in HKLM Software

Python PythonCore 2.7 InstallPath InstallGroup

• In my case it is Python 2.7

• Rerun the MySQL-python-1.2.3.win32-py2.7

• Click next and click Finish

Verification

• Type import MySQLdb

Step 2: Install Django

• Download Django tar file from the following location

https://www.djangoproject.com/download/1.5.5/tarball/• Copy and paste the tar file to C:\Python33

(where you have installed your python) as shown in the attachment

• Extract the files as shown

• Obtain the administrator command prompt by typing Window + X Allow the user control to make changes on the computer

• From the administrator command prompt, Go to the Django folder

• There will be a setup.py python file as shown in the screen shot.

• In the command prompt, type the command python setup.py install

• Press Enter

You can see something like this

Finally

• In order to verify that Django is installed, please type import django in the python command line as shown. If there is no error, you can confirm that it is installed successfully.

• Now python and Django framework are installed in your machine.

• Now for the IDE, you can install Aptana Studio.

Step3: Install Aptana Studio

• Download latest Aptana studio from http://www.aptana.com/

• Double click the set up to install Aptana Studio• It runs as a stand alone application.

Aptana Studio

Setting up Django in Aptana• Go to Window Preferences

• Click on Interpreter- Python under PyDev

Click on Auto Config• It asks for which python folders to select as

shown

Select the options that are already selected

• Click Ok and you can find a screen shown on the sideClick ApplyClick Ok

• Now you are ready to go

First sample Django project

• Click on File New Other

• Select PyDev PyDev Django Project

Click Next

• Provide the project name and click Next

• Select Django version as 1.4 or later. We had installed 1.5.5 (Refer the initial slides)

• Database Type : mysql (You can choose your database from the drop down list)

• Database Host: localhost (you can give the IP address if you are using a different system)

• Database Name: baabtra (Your database name) If you are using sqLite, the database will be created automatically. Other databases, you have to create the database before itself.

• Port number 3306 (Your port number)• Username : root (Username for connecting to the database)• Password : ******(Your password for the username above for

connecting to the database)• Please note that the above information will be stored in the

configuration file for connecting to the database.

• After filling the form • Click Finish

• For verification, right click the project root and Select Run As PyDev: Django

Another possible error

• The interpreter configured does not exist in the filesystem: C:\Python33\python.exe

• In my case the error happened because I had installed Python 3.3 and when I tried to install Python-mysql connector, it was available only for Python 2.6. So I had to remove Python 3.3 and install 2.6.

• Fix• Go to Window Preferences

Click on Auto Config

• Click OK

• Click Apply• And then Ok. • After that go to Project root folder Preference

• Click on “Click here to configure an interpreter not listed”

• Remove Python 3.3 by clicking Remove

• Click Apply• Click OK

Another Possible Error

• Traceback (most recent call last): File "C:\Users\admin\Documents\Aptana Studio 3 Workspace\BaabtraFirstDjango\manage.py", line 8, in <module> from django.core.management import execute_from_command_lineImportError: No module named django.core.management

Reason

• Django was installed on Python 3.3. Now it was reinstalled to Python 2.7. So we have to reinstall the Django framework.

• Follow the same steps as given in Step No.2 of this PPT

Final Verification• New Run As PyDev: Django

• From the console, copy and paste http://127.0.0.1:8000/ to a browser

Yes. It worked for you as well.

If this presentation helped you, please visit our page facebook.com/baabtra and like it.

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com

Recommended