Boston Python Workshop/Friday handout/Windows: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Paulproteus
(Copy paste from devchix)
 
imported>Brittag
(removing spam)
 
(48 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== About Django on Windows ==
----
== About Rails on Windows ==
* These instructions should work for all versions of Windows from XP on to Windows 7.
* These instructions should work for all versions of Windows from XP on to Windows 7.
* You may need to login as Administrator, or give the Administrator password when installing some programs, depending on your Windows version and user settings.
* You may need to login as Administrator, or give the Administrator password when installing some programs, depending on your Windows version and user settings.
== Open a Command Prompt ==
== Open a Command Prompt ==
* Open a command prompt window, and keep it open along with your browser. Much of installing Ruby and using Rails is typing commands and hitting '''<enter>'''. Your experience using Rails on Windows greatly depends on your making friends with the command prompt window.
* Open a command prompt window, and keep it open along with your browser. Much of installing Python and using Django is typing commands and hitting '''<enter>'''. Your experience using Python on Windows greatly depends on your making friends with the command prompt window.
* This is also called the command prompt, command window, command-line window, MS-DOS or DOS window.
* This is also called the command prompt, command window, command-line window, MS-DOS or DOS window.
http://www.wiki.devchix.com/index.php?title=Opening_a_command_prompt_window
[[Opening a command prompt window]]
* Try these recommendations:
* Try these recommendations:
http://www.wiki.devchix.com/index.php?title=Recommended_setup_for_command-line_windows
[[Recommended setup for command-line windows]]
* Tip: '''clear screen''' <br/>If you ever want to clear the &quot;output history&quot; to get a clear screen, type:
* Tip: '''clear screen''' <br/>If you ever want to clear the &quot;output history&quot; to get a clear screen, type:
<pre>
<pre>
Line 16: Line 15:
* Tip: '''copy and paste''' <br/>In the instructions below, where it says: &quot;In the command prompt type:&quot;, you can, much more easily, copy the command from this page, and right click in the menu bar or command prompt window, then click on &quot;Paste&quot;, then hit the '''&lt;enter&gt;''' key.
* Tip: '''copy and paste''' <br/>In the instructions below, where it says: &quot;In the command prompt type:&quot;, you can, much more easily, copy the command from this page, and right click in the menu bar or command prompt window, then click on &quot;Paste&quot;, then hit the '''&lt;enter&gt;''' key.


== Install Ruby ==
== Install Python ==
* Go to http://rubyinstaller.org/ and download Ruby 1.9.2 (or greater)
* Go to http://python.org/download/ and download the latest version of Python ''2.7'' (2.7.1 at the time of writing).
* Click on the downloaded file to install.
** ''Important'': Take note the folder where Ruby is installed. You will need the path of this folder later when installing SQLite. In this example below, the path is: <tt>C:\Ruby192</tt>
** Be sure to check ''both'' boxes, &quot;Add Ruby ... to your path&quot; and &quot;Associate ... files ...&quot;
[[File:Win7 rubyinstaller.jpg]]
* Test your Ruby install in the command prompt using the -v version flag
<pre>
ruby -v
</pre>
You should see something like
<pre>
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
</pre>


* Test your Python install in the command prompt:
== Install Ruby DevKit ==
This gets rid of the pop up that says something about Ruby 1.8dll can't be loaded.
* Download the Development Kit from rubyinstaller.org: http://rubyinstaller.org/downloads/
* Make a folder in your C:\ directory called RubyDevKit. Copy the downloaded file there, and then double-click to extract.
* In git bash:
<code><pre>
cd /c
cd RubyDevKit
ruby ./dk.rb init
ruby ./dk.rb install
</pre></code>
* Reinstall the json gem as specified here: http://www.shaunambrose.com/2010/11/11/how-to-fix-the-msvcrt-ruby18-dll-is-missing-from-your-computer-error-message-in-ruby-on-rails/


\python27\python.exe
== Install Bundler ==
* In the command prompt type:
<pre> gem install bundler --no-rdoc --no-ri </pre> You should see something like <pre> Successfully installed bundler-1.0.0 1 gem installed </pre>


You should see something like
== Install a Simple Code editor ==
This is one simple editor - you will have some
options later on.

The default editor 'notepad' doesn't understand
the UNIX newline '\n'

First we will download and choose 'save'
navigate to Computer => C:\ => Ruby192 => bin
*[http://downloads.sourceforge.net/project/scintilla/SciTE/2.22/Sc222.exe?r=http%3A%2F%2Fwww.scintilla.org%2FSciTEDownload.html&ts=1291176673&use_mirror=voxel SC222 SC1 Micro Editor]

If we save the file sc222.exe to C:\Ruby192\bin
it will be in our $PATH variable - $PATH is where
we store a list of directories that contain files to run.

== Install Bundle o Gems ==


Open up a new command window and type :
* bundle init
* SC222.exe Gemfile

You will see a new window with lines
one of which is :

source "http://rubygems.org"

In the Gemfile , in your editor add the following lines
<pre>
<pre>
Python 2.7.1 (r271:86832, ...) on win32
gem "rails", '3.0.3'
Type "help", "copyright", "credits" or "license" for more information.
gem "rspec-rails"
>>>
gem "gherkin"
gem "cucumber"
gem "cucumber-rails"
gem "database_cleaner"
gem "capybara"
gem "win32console"
gem "heroku"
gem "sqlite3-ruby"
</pre>
</pre>


* Type
Save the file and in the same command window run:
* bundle


exit()
Bundle will use the Gemfile to install each of the
gem libraries in the list.


and press Enter, and you are back to the command prompt.
You will see something like ...
<pre>
Successfully installed activesupport-3.0.0
Successfully installed builder-2.1.2
Successfully installed i18n-0.4.1
Successfully installed activemodel-3.0.0
Successfully installed rack-1.2.1
Successfully installed rack-test-0.5.6
Successfully installed rack-mount-0.6.13
Successfully installed tzinfo-0.3.23
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.0
Successfully installed arel-1.0.1
Successfully installed activerecord-3.0.0
Successfully installed activeresource-3.0.0
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.1
Successfully installed treetop-1.4.8
Successfully installed mail-2.2.6.1
Successfully installed actionmailer-3.0.0
Successfully installed thor-0.14.2
Successfully installed railties-3.0.0
Successfully installed rails-3.0.0
</pre>
as well as a few more

Test the Rails install. In the command prompt type:
<pre> rails -v </pre> You should see something like <pre> Rails 3.0.0 </pre>

If you try to run rails -v and it is not found - try this - or put up hand and ask for help!
<pre>gem install</pre>


== Install Git for Windows ==
== Install Git for Windows ==
* Go to http://code.google.com/p/msysgit/ (aka GitBash)
* Go to [https://code.google.com/p/msysgit/downloads/list the downloads page for GitBash]
** Click on the top &quot;Downloads&quot; tab
** Download the top .exe file link with the Summary something like &quot;Full installer for official Git 1.7.x.x&quot;
** Download the top .exe file link with the Summary something like &quot;Full installer for official Git 1.7.x.x&quot;
* Run the install.
* Run the install.

'''Note''': You can't just click through the installer. You have to answer some questions!

* In the &quot;Select Components&quot; dialog, make sure the checkboxes &quot;Associate ... configuration files ...&quot; and &quot;Use a TrueType font ...&quot; are checked.
* In the &quot;Select Components&quot; dialog, make sure the checkboxes &quot;Associate ... configuration files ...&quot; and &quot;Use a TrueType font ...&quot; are checked.

[[file:Win7_git_optional.jpg]]
* ''Important'': In the &quot;Adjusting your PATH environment&quot; dialog, make sure &quot;Run Git from the Windows Command Prompt&quot; is selected.
* ''Important'': In the &quot;Adjusting your PATH environment&quot; dialog, make sure &quot;Run Git from the Windows Command Prompt&quot; is selected.
[[File:Win7 git path.png]]
* In the &quot;Configuring the line ending conversions&quot; dialog, make sure &quot;Checkout Windows-style, commit Unix-style line endings&quot; is selected.
* In the &quot;Configuring the line ending conversions&quot; dialog, make sure &quot;Checkout Windows-style, commit Unix-style line endings&quot; is selected.
* To run git, open Programs &gt; Git &gt; '''Git Bash'''
[[File:Win7 git conversions.jpg]]
* To run git, open Programs &gt; Git &gt; Git Bash
* Then to test the Git install and see Git commands, type this into the '''Git Bash''' prompt:
* Then to test the Git install and see Git commands, in the command prompt type:
<pre>
<pre>
git
git
</pre>
</pre>

'''Note''': From here forward, when we need a command prompt, we'll use the '''Git Bash''' prompt, because it is more featureful.


== Configure Git ==
== Configure Git ==
* Set up Git with your name and email to tag your code changes. In the command prompt type:
* Set up Git with your name and email to tag your code changes. In the command prompt type:
<pre> git config --global user.name <Your ActualName> </pre>
git config --global user.name "''Your ActualName''"
* Replace ''Your ActualName'' with your actual name.
and:
<pre> git config --global user.email <YourEmail@domain.com> </pre>


* Tip: '''Colors'''
<br/>
To have colored output, in the command prompt type each line followed by '''<enter>''':
<pre>
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
</pre>


git config --global user.email YourEmail@domain.com
== Install SQLite ==
* Replace ''YourEmail@domain.com'' with your email address.
* Go to: http://www.sqlite.org/download.html
* Scroll down to the &quot;Precompiled Binaries For Windows&quot; section near the bottom of the page.
* Download the latest &quot;sqlite3-n_n.zip&quot;
** Contains: sqlite3.exe
* Download the latest &quot;sqlitedll-3_n_n.zip&quot;
** Contains: sqlite3.def, sqlite3.dll
* Double-click each zip file to open the archives
* Copy and paste each file into the \bin folder under where Ruby was installed.
** in the Install Ruby example above Ruby is installed in <tt>C:\Ruby192</tt>, so the three files would be copied into <tt>C:\Ruby192\bin</tt>


Test it:


git config --global user.name
git config --global user.email


=== Tip: Colors ===
To have colored output, in the command prompt type each line followed by '''<enter>''':

git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto


== Install SQLite Manager ==
== Install SQLite Manager ==
Line 186: Line 88:


== Install KomodoEdit ==
== Install KomodoEdit ==
You need a text editor to do Ruby. If you already have a preferred text editor, such as vi, emacs, jedit, etc., you can skip this step. It must be a plain text editor and not something with styling like Microsoft Word.
You need a text editor to do Python. If you already have a preferred text editor, such as vi, emacs, jedit, etc., you can skip this step. It must be a plain text editor and not something with styling like Microsoft Word.


'''When in doubt, use KomodoEdit.'''
'''When in doubt, use KomodoEdit.'''
Line 194: Line 96:


== Create an ssh public key ==
== Create an ssh public key ==
You'll need one of these to create your Heroku account in the next section.
You'll need one of these to work with Github.

* Open up a new GitBash window.
* Get into a GitBash window.
* <code>ssh-keygen -C &quot;''Your Actual Email''&quot; -t rsa</code> (email should match git config setting)
* <code>ssh-keygen -C ''Your Actual Email'' -t rsa</code> (email should match git config setting)
* Hit enter to accept default location for ssh key.
* Hit enter to accept default location for ssh key.
* Hit enter to accept blank passphrase (if computer is shared with other people, as in a work laptop, you should create a passphrase). Hit enter again to accept blank passphrase (or enter passphrase again).
* Hit enter to accept blank passphrase (if computer is shared with other people, as in a work laptop, you should create a passphrase). Hit enter again to accept blank passphrase (or enter passphrase again).
* [[Output of ssh-keygen command]]
* Your brand-new public key is now stored at <code>~/.ssh/id_rsa.pub</code>.


* Your brand-new public key is now stored at <code>.ssh/id_rsa.pub</code> inside your Windows profile.
== Create a Heroku Account ==
* http://heroku.com -&gt; Sign Up -&gt; enter email address (use the same email as you did with git and the ssh public key).
* Heroku will send you an activation email. Open it and click on the activation link. It will take you to the Heroku site. Enter and confirm your password. Hit Save.


'''Note''': The ''ssh-keygen'' command will give you a bunch of output. You don't have to record that output anywhere.
* '''If you have further heroku issues, try following [http://support.heroku.com/forums/43117/entries/32505 these directions] to install (or re-install) the client.'''


== Django ==
* You have already installed the heroku gems in the 'Bundle o Gems' step.


* Open a new GitBash window. Type each of these, and press enter at the end of the line.
== Verify you can create a new Rails app ==
* Open a new GitBash window and type the following with a return at the end of each line:
mkdir ~/Desktop/rails
cd ~/Desktop/rails
rails new test_app
* The first two commands should produce no output. The last command's output is voluminous. :)
* Once that's finished, type the following in the GitBash window with a return at the end of each line:
cd test_app
rails server
* The first command should produce no output. The second command will put out a bunch of output, then just sit there until you cancel it (2 steps from now).
* In your browser, go to http://localhost:3000 ([http://wiki.devchix.com/images/successful-rails-install.jpg screenshot of successful install]
* Back in the GitBash window where you ran <code>rails server</code>, type control-c to kill(stop) the server.


curl -L http://www.djangoproject.com/download/1.2.5/tarball/ -o Django-1.2.5.tar.gz
== Verify your database is set up ==
tar zxvf Django-1.2.5.tar.gz
* Open a new GitBash window.
cd Django-1.2.5
<pre>
/c/python27/python setup.py install
cd ~/Desktop/rails/test_app
cd ..
rails generate scaffold user name:string email:string address:text active:boolean
rake db:migrate
rails server
</pre>
In the browser, visit '''http://localhost:3000/users'''
click ''New user'' to create a user to make sure we can save to the database. (The window where you ran
<code>rails server</code> will display debugging information as you do so.)
In your GitBash window where you ran <code>rails server</code>, type control-c to kill(stop) the server.


== Verify git is working ==
== Verify you can create a new Django app ==
* Open a new GitBash window.
* Type the following commands:
<pre>
cd ~/Desktop/rails/test_app
git init
</pre>
This should generate output similar to:
<pre>
Initialized empty Git repository in c:/Documents and Settings/smei/Desktop/ruby_on_rails/test_app/.git/
</pre>
* Type the following commands:
** <code> git add .</code> (Note the dot) (May get line ending warnings; safe to ignore.)
** <code> git commit -m &quot;initial commit&quot;</code> ([[Output of initial check-in]])
** <code>git log</code> (We're just checking to make sure it worked. Verify that it has the right user and commit message.)


* Create a folder on the desktop called <code>django_projects</code>
== Verify Heroku is set up ==
* Open a new GitBash window and type the following:
cd Desktop/django_projects
/c/python27/scripts/django-admin.py startproject myproject
* Both commands should provide no output.
* Once that's finished, type the following in the Terminal window:
cd myproject
/c/python27/python manage.py runserver
* The first command should produce no output. The second command will put out a bunch of output, then just sit there until you cancel it (2 steps from now).
* In your browser, go to http://localhost:8000/
* Back in the Terminal window where you ran <code>manage.py runserver</code>, type control-c to kill the server.


== Cleanup ==
* Run your Text Editor
Ok, there is one more step. You won't be using the test project in the workshop; we just created it to make sure everything was working. '''You should delete it now to reduce confusion during the workshop.''' Don't worry about losing information; it just has the test project in it.
** use file-open to select Desktop/rails/test_app/Gemfile
** replace the sqlite3 entry in your Gemfile with this chunk of code (the first line is what was there originally, with # space put in front to comment it out).
<pre>
# gem 'sqlite3-ruby', :require =&gt; 'sqlite3'
group :production, :staging do
gem &quot;pg&quot;, &quot;0.9.0&quot;
end
group :development, :test do
gem &quot;sqlite3-ruby&quot;, :require =&gt; &quot;sqlite3&quot;
end
</pre>


* Exit the GitBash terminal
(Don't delete the rest of the gems, just replace the sqlite gem entry.)
* Drag the myproject folder (inside django_projects) to the Recycle Bin. Leave django_projects on the desktop.

* Open a new GitBash window and type the following commands:
<pre>cd ~/Desktop/rails/test_app</pre>
<pre>bundle update</pre> this rebuilds the Gemfile.lock file to reflect the change.
<pre>git add .</pre>
<pre>git commit -m "fixed the gemfile"</pre>
Also, as of now heroku requires you to specify a special stack if running rails3 so your create command needs to be like this:
<pre>heroku create --stack bamboo-mri-1.9.2</pre>

* Enter your Heroku email address and password. ([[Output of heroku create command]])
* To verify that the <code>heroku create</code> completed successfully, do <code>git remote show</code> and see if the list includes <code>heroku</code>.
* type:<code>git push heroku master</code>
* It may ask: &quot;The authenticity of host 'heroku.com (75.101.145.87)' can't be established. RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad. Are you sure you want to continue connecting (yes/no)?&quot; Type <code>yes</code> and hit ''<enter>''.
* [[Output of successful first deploy]]. Be sure to find your Heroku application name in the output. ([[What to do if git seems stuck]])
* In the GitBash window type: <code>heroku rake db:migrate</code> ([[Output of heroku rake db:migrate]])
* Go to your application's URL. You'll need your Heroku application name. The URL for your app is <code>''application name''.heroku.com</code> - so with the example output in the previous step, it would be <code>floating-winter-18.heroku.com</code>. Verify you see the welcome page. Leave this window open.
* In the browser, add <code>/users</code> to the end of the URL. Verify you see the user list page. Create a new user to verify you can write to the db on Heroku.
* If you are having issues ("Remote end hung up unexpectedly"), you might need to run "heroku keys:add"


== Congratulations! ==
== Congratulations! ==


You have everything you need to write a Ruby on Rails application.
You have everything you need to write a Django web application in Python.


...on '''your''' machine.
== Almost there! ==


The next set of directions help you use alwaysdata.com and its free-of-cost hosting.
'''Find a volunteer and have them watch the next steps. If this works - get a sticker from them for your computer!'''


== Install PuTTY ==
* <code>rails new suggestotron -m http://robotarmymade.com/611071.txt</code>
* <code>cd suggestotron</code>
* <code>rake cucumber</code>


PuTTY is a program we'll use to log in to the server where your Django code runs.
After running this, the last few lines of output should look something like this:
<code>11 scenarios (5 failed, 6 skipped)
84 steps (5 failed, 79 skipped)
0m0.998s
rake aborted!
Command failed with status (1): [bundle exec /Users/sasha/.rvm/rubies/ruby-...]


* Go to the [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html PuTTY download page]
(See full trace by running task with --trace)
* Choose the '''putty-0.60-installer.exe''' file.
</code>
* Run the installer, and now you will find PuTTY in

** '''Start'''->'''Programs'''->'''PuTTY'''
== Cleanup ==
Ok, there is one more step. You won't be using the test application in the workshop; we just created it to make sure everything was working. '''You should delete it now to reduce confusion during the workshop.''' Don't worry about losing information - you'll repeat all the steps tomorrow, but more slowly so you can better understand what's going on under the hood.


'''Now go back to the [https://openhatch.org/wiki/Setting_up_the_web_app#Section_3:_Configuring_your_accounts_on_the_web web app install instructions]'''
* Drag the test_app folder (inside rails) to the trash. Leave rails on the desktop.
* Delete the app from Heroku. Go to https://heroku.com/myapps and then click on your app name. Scroll to the bottom of the page and click Destroy App.

Latest revision as of 07:57, 18 August 2013

About Django on Windows

  • These instructions should work for all versions of Windows from XP on to Windows 7.
  • You may need to login as Administrator, or give the Administrator password when installing some programs, depending on your Windows version and user settings.

Open a Command Prompt

  • Open a command prompt window, and keep it open along with your browser. Much of installing Python and using Django is typing commands and hitting <enter>. Your experience using Python on Windows greatly depends on your making friends with the command prompt window.
  • This is also called the command prompt, command window, command-line window, MS-DOS or DOS window.

http://www.wiki.devchix.com/index.php?title=Opening_a_command_prompt_window

  • Try these recommendations:

http://www.wiki.devchix.com/index.php?title=Recommended_setup_for_command-line_windows

  • Tip: clear screen
    If you ever want to clear the "output history" to get a clear screen, type:
cls
  • Tip: command history
    The command prompt window stores a "command history." To view and re-run previous commands, use the <up arrow> and <down arrow> keys. You can also edit a previous command and run it--this is handy for long commands, or fixing mistakes.
  • Tip: copy and paste
    In the instructions below, where it says: "In the command prompt type:", you can, much more easily, copy the command from this page, and right click in the menu bar or command prompt window, then click on "Paste", then hit the <enter> key.

Install Python

  • Test your Python install in the command prompt:
\python27\python.exe

You should see something like

Python 2.7.1 (r271:86832, ...) on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
  • Type
exit()

and press Enter, and you are back to the command prompt.

Install Git for Windows

  • Go to the downloads page for GitBash
    • Download the top .exe file link with the Summary something like "Full installer for official Git 1.7.x.x"
  • Run the install.

Note: You can't just click through the installer. You have to answer some questions!

  • In the "Select Components" dialog, make sure the checkboxes "Associate ... configuration files ..." and "Use a TrueType font ..." are checked.
  • Important: In the "Adjusting your PATH environment" dialog, make sure "Run Git from the Windows Command Prompt" is selected.
  • In the "Configuring the line ending conversions" dialog, make sure "Checkout Windows-style, commit Unix-style line endings" is selected.
  • To run git, open Programs > Git > Git Bash
  • Then to test the Git install and see Git commands, type this into the Git Bash prompt:
git

Note: From here forward, when we need a command prompt, we'll use the Git Bash prompt, because it is more featureful.

Configure Git

  • Set up Git with your name and email to tag your code changes. In the command prompt type:
git config --global user.name "Your ActualName"
  • Replace Your ActualName with your actual name.


git config --global user.email YourEmail@domain.com
  • Replace YourEmail@domain.com with your email address.

Test it:

git config --global user.name
git config --global user.email


Tip: Colors

To have colored output, in the command prompt type each line followed by <enter>:

git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto

Install SQLite Manager

  • If you already have Firefox installed, verify that it is version 3.5.0 or greater. (Help -> About Mozilla Firefox. The version number is right under the "Firefox" title.)
  • If you don't have Firefox installed, or it's an older version, install Firefox.
  • Once it's installed, open Firefox and go to Tools -> Add-ons. At the top of the add-ons window, click "Get Add-ons."
  • There will be search box directly underneath "Get Add-ons" that says "Search All Add-ons." Enter "SQLite" (without the quotes) in the box and hit enter.
  • SQLite Manager should be the top result. Click "Add to Firefox..." (If SQLite Manager isn't in the results, check the spelling - SQLite only has one L. Also, check that you have at least Firefox 3.5.)
  • Wait for the countdown, then click "Install Now."
  • In the Add-ons windows, click "Restart Firefox."
  • Once Firefox restarts, the Add-ons window should say "1 new add-on has been installed." Go to the Tools menu and verify that there is an option for SQLite Manager.


Install KomodoEdit

You need a text editor to do Python. If you already have a preferred text editor, such as vi, emacs, jedit, etc., you can skip this step. It must be a plain text editor and not something with styling like Microsoft Word.

When in doubt, use KomodoEdit.

Create an ssh public key

You'll need one of these to work with Github.

  • Get into a GitBash window.
  • ssh-keygen -C Your Actual Email -t rsa (email should match git config setting)
  • Hit enter to accept default location for ssh key.
  • Hit enter to accept blank passphrase (if computer is shared with other people, as in a work laptop, you should create a passphrase). Hit enter again to accept blank passphrase (or enter passphrase again).
  • Your brand-new public key is now stored at .ssh/id_rsa.pub inside your Windows profile.

Note: The ssh-keygen command will give you a bunch of output. You don't have to record that output anywhere.

Django

  • Open a new GitBash window. Type each of these, and press enter at the end of the line.
curl -L  http://www.djangoproject.com/download/1.2.5/tarball/  -o Django-1.2.5.tar.gz
tar zxvf Django-1.2.5.tar.gz
cd Django-1.2.5
/c/python27/python setup.py install
cd ..

Verify you can create a new Django app

  • Create a folder on the desktop called django_projects
  • Open a new GitBash window and type the following:
   cd Desktop/django_projects
   /c/python27/scripts/django-admin.py startproject myproject
  • Both commands should provide no output.
  • Once that's finished, type the following in the Terminal window:
   cd myproject
   /c/python27/python manage.py runserver
  • The first command should produce no output. The second command will put out a bunch of output, then just sit there until you cancel it (2 steps from now).
  • In your browser, go to http://localhost:8000/
  • Back in the Terminal window where you ran manage.py runserver, type control-c to kill the server.

Cleanup

Ok, there is one more step. You won't be using the test project in the workshop; we just created it to make sure everything was working. You should delete it now to reduce confusion during the workshop. Don't worry about losing information; it just has the test project in it.

  • Exit the GitBash terminal
  • Drag the myproject folder (inside django_projects) to the Recycle Bin. Leave django_projects on the desktop.

Congratulations!

You have everything you need to write a Django web application in Python.

...on your machine.

The next set of directions help you use alwaysdata.com and its free-of-cost hosting.

Install PuTTY

PuTTY is a program we'll use to log in to the server where your Django code runs.

  • Go to the PuTTY download page
  • Choose the putty-0.60-installer.exe file.
  • Run the installer, and now you will find PuTTY in
    • Start->Programs->PuTTY

Now go back to the web app install instructions