Baabtra django framework installation and sample project using aptana

59

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.

Transcript of Baabtra django framework installation and sample project using aptana

Page 1: Baabtra django framework installation and sample project using aptana
Page 2: Baabtra django framework installation and sample project using aptana

• 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?

Page 3: Baabtra django framework installation and sample project using aptana

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

Haris [email protected]/haris.np9twitter.com/np_harisin.linkedin.com/in/harisnp

Page 4: Baabtra django framework installation and sample project using aptana

Steps

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

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

Page 5: Baabtra django framework installation and sample project using 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

Page 6: Baabtra django framework installation and sample project using aptana

• Python 2.7 and Python 3.3

Page 7: Baabtra django framework installation and sample project using aptana

• 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

Page 8: Baabtra django framework installation and sample project using aptana

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

Page 9: Baabtra django framework installation and sample project using aptana

• Double click on the EXE file

Page 10: Baabtra django framework installation and sample project using aptana

Now you might get this error

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

Page 11: Baabtra django framework installation and sample project using aptana

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

Page 12: Baabtra django framework installation and sample project using aptana

What to do?

• Open Run (Window + R)• Type regedit

Page 13: Baabtra django framework installation and sample project using aptana

• Go to Wow6432Node as shown

Page 14: Baabtra django framework installation and sample project using aptana

• Click Edit New Key

Page 15: Baabtra django framework installation and sample project using aptana

• Create Folder Python

Page 16: Baabtra django framework installation and sample project using aptana

• Repeat the same steps by choosing the folder Python

• Create the folder structure• Python PythonCore 2.7 InstallPath

InstallGroup

Page 17: Baabtra django framework installation and sample project using aptana

• Double click on (Default) as shown

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

Page 18: Baabtra django framework installation and sample project using aptana

• 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

Page 19: Baabtra django framework installation and sample project using aptana

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

Page 20: Baabtra django framework installation and sample project using aptana

• Click next and click Finish

Page 21: Baabtra django framework installation and sample project using aptana

Verification

• Type import MySQLdb

Page 22: Baabtra django framework installation and sample project using aptana

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

Page 23: Baabtra django framework installation and sample project using aptana
Page 24: Baabtra django framework installation and sample project using aptana

• Extract the files as shown

Page 25: Baabtra django framework installation and sample project using aptana

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

Page 26: Baabtra django framework installation and sample project using aptana

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

Page 27: Baabtra django framework installation and sample project using aptana

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

Page 28: Baabtra django framework installation and sample project using aptana

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

• Press Enter

Page 29: Baabtra django framework installation and sample project using aptana

You can see something like this

Page 30: Baabtra django framework installation and sample project using aptana

Finally

Page 31: Baabtra django framework installation and sample project using aptana

• 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.

Page 32: Baabtra django framework installation and sample project using aptana

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

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

Page 33: Baabtra django framework installation and sample project using aptana

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.

Page 34: Baabtra django framework installation and sample project using aptana

Aptana Studio

Page 35: Baabtra django framework installation and sample project using aptana

Setting up Django in Aptana• Go to Window Preferences

Page 36: Baabtra django framework installation and sample project using aptana

• Click on Interpreter- Python under PyDev

Page 37: Baabtra django framework installation and sample project using aptana

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

shown

Page 38: Baabtra django framework installation and sample project using aptana

Select the options that are already selected

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

Page 39: Baabtra django framework installation and sample project using aptana

• Now you are ready to go

Page 40: Baabtra django framework installation and sample project using aptana

First sample Django project

• Click on File New Other

Page 41: Baabtra django framework installation and sample project using aptana

• Select PyDev PyDev Django Project

Page 42: Baabtra django framework installation and sample project using aptana

Click Next

• Provide the project name and click Next

Page 43: Baabtra django framework installation and sample project using aptana

• 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.

Page 44: Baabtra django framework installation and sample project using aptana

• After filling the form • Click Finish

Page 45: Baabtra django framework installation and sample project using aptana

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

Page 46: Baabtra django framework installation and sample project using aptana

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.

Page 47: Baabtra django framework installation and sample project using aptana

• Fix• Go to Window Preferences

Page 48: Baabtra django framework installation and sample project using aptana

Click on Auto Config

• Click OK

Page 49: Baabtra django framework installation and sample project using aptana

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

Page 50: Baabtra django framework installation and sample project using aptana
Page 51: Baabtra django framework installation and sample project using aptana

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

• Remove Python 3.3 by clicking Remove

Page 52: Baabtra django framework installation and sample project using aptana

• Click Apply• Click OK

Page 53: Baabtra django framework installation and sample project using aptana

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

Page 54: Baabtra django framework installation and sample project using aptana

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

Page 55: Baabtra django framework installation and sample project using aptana

Final Verification• New Run As PyDev: Django

Page 56: Baabtra django framework installation and sample project using aptana

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

Page 57: Baabtra django framework installation and sample project using aptana

Yes. It worked for you as well.

Page 58: Baabtra django framework installation and sample project using aptana

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

Page 59: Baabtra django framework installation and sample project using aptana