Getting started with Django on Windows

1,467 views

Published on

Django Book Ch2: Getting started - Windows version

Published in: Technology

Getting started with Django on Windows

  1. 1. Getting started with Djangoon WindowsMichelle Leu (flywindy)2013/05/28
  2. 2. 2Agenda Before install Django1. (Optional) Install PowerShell (Download)2. Install Python3. (Optional) Install pip Install Django Run server
  3. 3. 3Unlike most Unix systems and services,Windows does not require Python nativelyand thus does not pre-install a version ofPython.Install Python
  4. 4. 4Step 1: Download Python The core Django framework works with anyPython version from 2.5 to 2.7, inclusive.1. Go to Python’s Download page.2. Click the link to download installer, it’s depends onyour windows system is 32-bit or 64-bit.3. The latest version: 2.7.532-bit64-bit
  5. 5. 5Step 2: Run installer1. Click the file you downloaded, and run theinstaller.2. Select a directory for Python, for example Ichoose C disk.
  6. 6. 6Step 3: Setup pathC:Python27;
  7. 7. 7Step 4: Try it! “Hello world”1. Open “Python (command line)”, or open cmd(powershell) and input “python”2. Type print “Hello world”3. If output “Hello world”, it works.
  8. 8. 8pip works on Unix/Linux, OS X, andWindows.(Optional) Install pip
  9. 9. 9Install pip Option 11. Download the get-pip.py script2. Run it using Python C:> python get-pip.py Option 21. Download and install it.
  10. 10. 10Requirements files1. Create a requirements file something like:2. If you save this in pip-requirements.txt, thenyou can type this on you commend line: pip install -r pip-requirements.txtDjango==1.4.5……
  11. 11. 11If you are upgrading your installation ofDjango from a previous version, you willneed to uninstall the old Django versionbefore installing the new version.Install Django
  12. 12. 12Install Django Installing an official release with pip $ pip install django (or use requirements file.) Installing an official release manually (ex:version 1.4.3)1. Go to Django’s download page.
  13. 13. 13Install Django2. Click “Django-1.4.3.tar.gz” to download.3. Unzip this file to get the folder called “Django-1.4.3”.4. Open your commend line, cd into the folder,and input “python setup.py install” to installsetup.py, and you will see it’s installing now!
  14. 14. 14Step 3: Try it!1. In cmd or powershell, input “python” then youcan open Python’s command line.2. Input “import django”, and “django.VERSION”,you can see the version, that means djangoalready installed.Version: 1.4.5
  15. 15. 15Step 4: setup path1. Go to “Environment Variables” again, edit“Path” variable, add value“;C:Python27Scripts”, click “OK” to save.2. Test it: open cmd(powershell), input “django-admin.py” then you will see some options, it’sworks.
  16. 16. 16Create new django project
  17. 17. 17Step 1: create project We use “django-admin.py startproject[projectname]” to create project, for examplethe project name is “mysite”.1. Open cmd(powershell), go to the folder thatyou want to put project, input “django-admin.py startproject mysite” ,then you cansee the new project already in your folder.
  18. 18. 18Step 2: run server1. In your project, input “python manage.pyrunserver”, if see “Development server isrunning at http://127.0.0.1:8000/”,then go tothe link, you can see “It worked!”.
  19. 19. 19Reference Using Python on Windows The Django Book Django doc Unofficial Windows Binaries for PythonExtension Packages (ex: pip or PIL…) Pip requirements files
  20. 20. Thanks for your listening :)

×