start to add some initial target test articles

pull/4/merge
Richard Harding 12 years ago
parent 31c4439155
commit 5e95f531bc

@ -0,0 +1,678 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<script type='text/javascript'>var _sf_startpt=(new Date()).getTime()</script>
<title>1859's &quot;Great Auroral Storm&quot;&mdash;the week the Sun touched the earth</title>
<!-- Begin CSS -->
<link rel="stylesheet" type="text/css" href="http://static.arstechnica.net//public/v6/styles/light/light.c.css?1335816272" media="screen" />
<link rel="stylesheet" type="text/css" href="http://static.arstechnica.net//public/v6/styles/print/print.css?1335816272" media="print" />
<!-- End CSS -->
<link rel="apple-touch-icon" href="http://static.arstechnica.net/apple-touch-icon.png" />
<link rel="canonical" href="http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars" />
<link rel="shorturl" href="http://arst.ch/tmc" />
<link rel="shortlink" href="http://arst.ch/tmc" />
<link rev="canonical" href="http://arst.ch/tmc" />
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Ars Technica" />
<link rel="shortcut icon" href="http://static.arstechnica.net/favicon.ico" />
<link rel="icon" type="image/x-icon" href="http://static.arstechnica.net/favicon.ico" />
<!-- Begin Feeds -->
<link rel="alternate" type="application/rssxml" title="Nobel Intent" href="http://feeds.arstechnica.com/arstechnica/science/" />
<link rel="alternate" type="application/rss+xml" title="All Articles " href="http://feeds.arstechnica.com/arstechnica/everything" />
<!-- End Feeds -->
<!-- C-razy IE9 stuff -->
<meta name="application-name" content="Ars Technica"/>
<meta name="msapplication-starturl" content="http://arstechnica.com/"/>
<meta name="msapplication-tooltip" content="Ars Technica: Serving the technologist for 1.2 decades"/>
<meta name="msapplication-task" content="name=News;action-uri=http://arstechnica.com/;icon-uri=http://arstechnica.com/favicon.ico"/>
<meta name="msapplication-task" content="name=Features;action-uri=http://arstechnica.com/features/;icon-uri=http://static.arstechnica.net/ie-jump-menu/jump-features.ico"/>
<meta name="msapplication-task" content="name=OpenForum;action-uri=http://arstechnica.com/civis/;icon-uri=http://static.arstechnica.net/ie-jump-menu/jump-forum.ico"/>
<meta name="msapplication-task" content="name=One Microsoft Way;action-uri=http://arstechnica.com/microsoft/;icon-uri=http://static.arstechnica.net/ie-jump-menu/jump-omw.ico"/>
<meta name="msapplication-task" content="name=Subscribe;action-uri=http://arstechnica.com/subscriptions/;icon-uri=http://static.arstechnica.net/ie-jump-menu/jump-subscribe.ico"/>
<!-- Begin Metadata -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=1000" />
<meta name="description" content="150 years ago, the world was engulfed in the largest electromagnetic storm on record, the &quot;Carrington Event&quot; of 1859. How did humanity react to the week-long solar maelstrom, and what will we do when it happens again?" />
<meta name="keywords" content="carringtonevent, greatauroralstormof1859, magneticstorm" />
<meta name="title" content="1859's &quot;Great Auroral Storm&quot;&mdash;the week the Sun touched the earth" />
<link rel="image_src" href="http://static.arstechnica.net/assets/2012/04/sun-eruption-4f9e9cc-listing-thumb-300x169-33537-f.jpg" />
<meta name="medium" content="news" />
<meta name="entry_id" content="55765" />
<meta property="og:title" content="1859's &quot;Great Auroral Storm&quot;&mdash;the week the Sun touched the earth"/>
<meta property="og:site_name" content="Ars Technica"/>
<meta property="og:image" content="http://static.arstechnica.net/assets/2012/04/sun-eruption-4f9e9cc-listing-thumb-300x169-33537-f.jpg"/>
<meta name="advertising" content="ask" />
<meta property="fb:admins" content="13703630" />
<!-- End Metadata -->
<!-- Entry - culture_science -->
<style type="text/css" id="resource-styles"> </style>
<script type="text/javascript" src="http://static.arstechnica.com/public/shared/scripts/da-1.5.js"></script>
<script type="text/javascript">
try {
cnp.ad.dart.setSite("ars.dart");
cnp.ad.dart.setZone('culture_science');
//cnp.ad.dart.addParameterString('kw=1859s-great-auroral-stormthe-week-the-sun-touched-the-earth;kw=05;kw=2012;kw=news;kw=science;');
cnp.ad.emptyFrameSrc="/public/shared/scripts/empty.html";
cnp.ad.loaderFrameSrc="/public/shared/scripts/ad-loader-frame.html";
} catch(e) {}
</script>
<script type="text/javascript" charset="utf-8">
// In case someone on a desktop clicks a mobile #! link
var l = window.location;
if(l.hash.indexOf('#!') !== -1){
window.location = l.protocol + '//' + l.host + l.hash.slice(2);
}
</script>
</head>
<body class="individual">
<div id="page" class="">
<div id="masthead" class="">
<div id="logo"><a href="/"><img src="http://static.arstechnica.net//public/v6/styles/light/images/masthead/logo.png?1335816272" alt="Ars Technica: The Art of Technology" width="110" height="81" /></a></div>
<div id="ebc51ce07629d0e14d2fbc4236e44067" >
<script type="text/javascript">
var pbanner_start = new Date();
try {
var pbanner = cnp.ad.create(cnp.ad.refreshable, false);
//pbanner.addParameter({'dcopt':'ist'});
pbanner.addParameterString('kw=top;kw=1859s-great-auroral-stormthe-week-the-sun-touched-the-earth;kw=05;kw=2012;kw=news;kw=science;');
pbanner.addParameter({'sz': '728x90' });
} catch(e) {}
</script>
</div>
</div>
<div id="search-navigation">
<div id="search">
<a id="search-link" href="http://www.google.com/cse?cx=011835048811694782689:7zpko-isndo">Search</a>
<div class="form">
<span>Search:</span>
<form action="http://www.google.com/cse" id="search-form">
<div>
<input type="hidden" value="011835048811694782689:7zpko-isndo" name="cx"/>
<input type="hidden" value="UTF-8" name="ie"/>
<input type="text" id="search-form-text" value="" name="q"/>
</div>
</form>
</div>
</div>
<div id="navigation">
<ul id="primary-navigation">
<li class=""><a href="/">All</a></li>
<li class="apple"><a href="/apple/">Apple</a></li>
<li class="ask-ars"><a href="/ask-ars/">Ask Ars</a></li>
<li class="business"><a href="/business/">Business</a></li>
<li class="gadgets"><a href="/gadgets/">Gadgets</a></li>
<li class="gaming"><a href="/gaming/">Gaming</a></li>
<li class="microsoft"><a href="/microsoft/">Microsoft</a></li>
<li class="open-source"><a href="/open-source/">Open Source</a></li>
<li class="science selected"><a href="/science/">Science</a></li>
<li class="tech-policy"><a href="/tech-policy/">Tech Policy</a></li>
<li id="primary-navigation-more" style="display:none;">
More
<ul >
<li><a href="/hardware/">Hardware</a></li>
<li><a href="/media/">Media</a></li>
<li><a href="/security/">Security</a></li>
<li><a href="/software/">Software</a></li>
<li><a href="/staff/">Staff</a></li>
<li><a href="/telecom/">Telecom</a></li>
<li><a href="/web/">Web</a></li>
<li><a href="/site/tv.ars" title="Ars Technica TV">Ars.TV</a></li>
<li style="padding:0;"><span style="display:inline;background-color: #920404; padding: 3px; color:white; -webkit-border-radius: 4px;">New</span> <a style="display:inline;" href="/getting-it-done" title="Getting IT Done">Getting IT Done</a></li>
</ul>
</li>
</ul>
<ul id="secondary-navigation" class="science">
<li class="news selected"><a href="/science/news/">News</a></li>
<li class="guides"><a href="/science/guides/">Guides</a></li>
<li class="reviews"><a href="/science/reviews/">Reviews</a></li>
</ul>
<ul id="auxiliary-navigation">
<li class="subscribe"><a href="/subscriptions/">Upgrade to a Premier Subscription</a>
</li>
<li class="customize" style="display:none;">
<a href="#">Customize ▾</a>
<ul>
<li>
<p>Site Theme:</p>
<label><input type="radio" checked="checked" value="light.css" class="site-style" name="site-style" /> White</label>
<label><input type="radio" value="dark.css" class="site-style" name="site-style" /> Black</label>
</li>
<li>
<p>Choose body font:</p>
<label><input type="radio" checked="checked" value="arial" class="body_font" name="body_font" /> Arial</label>
<label><input type="radio" value="helvetica" class="body_font" name="body_font" /> Helvetica</label>
</li>
</ul>
</li>
<li class="openforum"><a href="http://arstechnica.com/civis/">OpenForum</a></li>
<li class="login-join"><a href="/civis/ucp.php?mode=login&amp;return_to=http%3A%2F%2Farstechnica.com%2Fscience%2Fnews%2F2012%2F05%2F1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars">Login/Join</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="silo-header" class="">
<h1 class="science"><a href="/science/" title="Go to Nobel Intent">Nobel Intent</a></h1>
</div>
<div id="content" class="normal"> <div id="content-inner">
<div id="story">
<h2 class="title">1859's "Great Auroral Storm"&#8212;the week the Sun touched the earth</h2>
<div class="byline"><span class="author">By <a rel="author" href="/author/matthew-lasar/">Matthew Lasar</a>
</span> | <span class="posted"><span class="published"><span class="name">Published </span> <abbr class="timeago datetime" title="2012-05-03T1:00:00Z">May 2, 2012 8:00 PM</abbr></span></span></div>
<div class="story-image CenteredImage" style="width:640px;">
<img width="640" src="http://static.arstechnica.net/assets/2012/04/magnetogram2-4f9c6a2-intro-thumb-640xauto-33524.jpg" alt="1859's &quot;Great Auroral Storm&quot;&amp;#8212;the week the Sun touched the earth" />
<div class="news-item-figure-caption"><div class="news-item-figure-caption-text">A magnetogram recorded at the Greenwich Observatory in London during the Carrington Event of 1859.</div></div>
</div>
<div id="" class="body" style="">
<!--body--><p>Noon approached on September 1, 1859, and British astronomer <a href="http://en.wikipedia.org/wiki/Richard_Christopher_Carrington">Richard Christopher Carrington</a> was busy with his favorite pastime: tracking sunspots, those huge regions of the star darkened by shifts in its magnetic field. He projected the Sun's image from his viewing device onto a plate of glass stained a "pale straw colour," which gave him a picture of the fiery globe one inch shy of a foot in diameter.</p>
<p>The morning's work went as normal. Carrington patiently counted and charted spots, time-lining changes in their positions with a chronometer. Then he saw something unusual.</p><!--page 1-->
<div style="width: 300px;" class="news-item-figure ImageRight"><div class="news-item-figure-image" style="height: 169px;"><img src="http://static.arstechnica.net/2012/04/28/carrington-4f9c68d-listing.jpg" height="169" alt="Richard Carrington's 1859 drawing of the solar flares he identified while sunspot watching. The intensely bright patches are marked A and B." width="300" /></div><div class="news-item-figure-caption"><div class="news-item-figure-caption-text">Richard Carrington's 1859 drawing of the solar flares he identified while sunspot watching. The "intensely bright" patches are marked A and B.</div><div class="news-item-figure-caption-byline"><a href="http://articles.adsabs.harvard.edu//full/seri/MNRAS/0020//0000013.000.html">SAO/Nasa Astrophysics</a></div></div></div>
<p>"Two patches of intensely bright and white light broke out," <a href="http://adsbit.harvard.edu/cgi-bin/nph-iarticle_query?bibcode=1859MNRAS..20...13C">he later wrote</a>. Carrington puzzled over the flashes. "My first impression was that by some chance a ray of light had penetrated a hole in the screen attached to the object-glass," he explained, given that "the brilliancy was fully equal to that of direct sun-light."</p>
<p>The astronomer checked his gear. He moved the apparatus around a bit. To his surprise, the intense white patches stayed put. Realizing that he was an "unprepared witness of a very different affair," Carrington ran out of his studios to find a second observer. But when he brought this person back, he was "mortified to find" that the bright sections were "already much changed and enfeebled."</p>
<p>"Very shortly afterwards the last trace was gone," Carrington wrote. He kept watch on the region for another hour, but saw nothing more. Meanwhile, the explosive energy that he had seen rushed towards him and everyone else on earth.</p>
<h3>Better than batteries</h3>
<p>It hit quickly. Twelve hours after Carrington's discovery and a continent away, "We were high up on the Rocky Mountains sleeping in the open air," wrote a correspondent to the <em>Rocky Mountain News</em>. "A little after midnight we were awakened by the auroral light, so bright that one could easily read common print." As the sky brightened further, some of the party began making breakfast on the mistaken assumption that dawn had arrived.</p>
<p>Across the United States and Europe, telegraph operators struggled to keep service going as the electromagnetic gusts enveloped the globe. In 1859, the US telegraph system was about 20 years old, and <a href="http://arstechnica.com/telecom/news/2010/02/the-lost-souls-of-telecommunications-history.ars/2">Cyrus Field</a> had just built his transatlantic cable from Newfoundland to Ireland, which would not succeed in transmitting messages until after the American Civil War. </p>
<p>"Never in my experience of fifteen years in working telegraph lines have I witnessed anything like the extraordinary
effect of the Aurora Borealis between Quebec and Farther Point last night," wrote one telegraph manager to the <em>Rochester Union &amp; Advertiser</em> on August 30:</p>
<blockquote>
<p>The line was in most perfect order, and well skilled operators worked incessantly from 8 o'clock last evening till one this morning to get over in an intelligible form four hundred words of the report per steamer Indian for the Associated Press, and at the latter hour so completely were the wires under the influence of the Aurora Borealis that it was found utterly impossible to communicate between the telegraph stations, and the line had to be closed.</p>
</blockquote>
<p>But if the following newspaper transcript of a telegraph operator exchange between Portland and Boston is to be believed, some plucky telegraphers improvised, letting the storm do the work that their disrupted batteries couldn't:</p>
<blockquote>
<p>Boston operator, (to Portland operator) - "Please cut off your battery entirely from the line for fifteen minutes." </p>
<p> Portland operator - "Will do so. It is now disconnected."</p>
<p> Boston - "Mine is disconnected, and we are working with the auroral current. How do you receive my writing?"</p>
<p> Portland - "Better than with our batteries on. Current comes and goes gradually."</p>
<p> Boston - "My current is very strong at times, and we can work better without the batteries, as the Aurora seems to neutralize and augment our batteries alternately, making current too strong at times for our relay magnets. </p>
<p> Suppose we work without batteries while we are affected by this trouble."</p>
<p> Portland - "Very well. Shall I go ahead with business?"</p>
<p> Boston - "Yes. Go ahead."</p>
</blockquote>
<p>Telegraphers around the US reported similar experiences. "The wire was then worked for about two hours without the usual batteries on the auroral current, working better than with the batteries connected," said the <em>Washington Daily National Intelligencer</em>. "Who now will dispute the theory that the Aurora Borealis is caused by electricity?" asked the <em>Washington Evening Star</em>.</p>
<div style="width: 550px;" class="news-item-figure CenteredImage"><div class="news-item-figure-image" style="height: 319px;"><img src="http://static.arstechnica.net/2012/04/28/magnetogram1-4f9c6be-intro.jpg" height="319" alt="A magnetogram recorded at the Greenwich Observatory in London during the Carrington Event of 1859. The lower line (D) represents compass direction; the upper line (H) represents magnetic field horizontal force." width="550" /></div><div class="news-item-figure-caption"><div class="news-item-figure-caption-text">A magnetogram recorded at the Greenwich Observatory in London during the Carrington Event of 1859. The lower line (D) represents compass direction; the upper line (H) represents horizontal force.</div><div class="news-item-figure-caption-byline"><a href="http://www.geomag.bgs.ac.uk/education/carrington.html">British Geological Survey</a></div></div></div>
<p>Working with solar-powered telegraph lines sometimes proved to be risky, however. As the sky filled with light, East Coast telegrapher Frederic Royce struggled to get his messages to Richmond, Virginia, his hand resting on the iron plate of his gear. Distracted by the displays, he also leaned on the system's "sounder," which indicated by audio whether the circuit was connected or not. At the same time, his forehead touched its ground wire. </p>
<p>"Immediately, I received a very severe electric shock, which stunned me for an instant," Royce wrote to <em>The New York Times</em>. "An old man who was sitting facing me, and but a few feet distant, said that he saw a spark of fire jump from my forehead." </p>
<p>The night of Carrington's discovery, the electrical hurricane that had swept the globe peaked. The Great Auroral Storm had actually begun several days earlier with a similar incident on August 28, but it was Carrington and another astronomer, Richard Hodgson, who identified one of the solar flares that enveloped the earth in a week-long magnetic maelstrom. Because of their work, the episode was dubbed the "Carrington Event," and it consumed the world's attention for the week.</p>
<h3>A livid red flame</h3>
<div style="width: 640px;" class="news-item-figure CenteredImage"><div class="news-item-figure-image" style="height: 425px;"><img src="http://static.arstechnica.net/2012/04/28/churchauroraborealis-4f9c6ef-intro.jpg" height="425" alt="Frederic Edwin Church's 1859 painting Aurora Borealis. Some speculate that Church took his inspiration from the Great Auroral Storm of 1859." width="640" /></div><div class="news-item-figure-caption"><div class="news-item-figure-caption-text">Frederic Edwin Church's 1865 painting "Aurora Borealis." Some speculate that Church took his inspiration from the Great Auroral Storm of 1859.</div><div class="news-item-figure-caption-byline"><a href="http://en.wikipedia.org/wiki/File:Frederic_Edwin_Church_Aurora_Borealis.jpg">Wikipedia</a></div></div></div>
<p>In New York City, San Francisco, Boston, and Chicago, thousands of sky gazers wandered about the midnight streets, astounded at what they could see. "Crowds of people gathered at the street corners, admiring and commenting upon the singular spectacle," observed the <em>New Orleans Daily Picayune</em>. When the September 1 aurora "was at its greatest brilliancy, the northern heavens were perfectly illuminated," wrote a reporter for <em>The New York Times.</em> He continued:</p>
<blockquote>
<p>At that time almost the whole southern heavens were in a livid red flame, brightest still in the southeast and southwest. Streamers of yellow and orange shot up and met and crossed each other, like the bayonets upon a stack of guns, in the open space between the constellations Aries, Taurus and the Head of Medusa&#8212;about 15 degrees south of the zenith. In this manner&#8212;alternating great pillars, rolling cumuli shooting streamers, curdled and wisped and fleecy waves&#8212;rapidly changing its hue from red to orange, orange to yellow, and yellow to white, and back in the same order to brilliant red, the magnificent auroral glory continued its grand and inexplicable movements until the light of morning overpowered to radiance and it was lost in the beams of the rising sun.</p>
</blockquote>
<p>Popular descriptions of the spectacle appeared everywhere. In 2006, a team of space scientists assembled <a href="http://www.sciencedirect.com/science/article/pii/S0273117706000160">a collection of eyewitness newspaper accounts</a> of the storm. What stands out in these reports is the astonishment, awe, and even pleasure that the world experienced for a week&#8212;followed by a sobering realization of how close our planet is to its indispensable star. </p>
<p>In Cincinnati, the aurora came "like that preceding the rising moon, while in the west a delicate crimson seemed to be thrown upwards, as if from the sun, long since gone down," wrote a journalist for the <em>Cincinnati Daily Commercial.</em></p>
<blockquote>
<p>Later, these strange fires overran the entire heavens&#8212;now separating into streamers, gathered at the zenith, and forming a glorious canopy&#8212;then spreading evenly like a vapor, shedding on all things a soft radiance; again, across the sky waves of light would flit, like the almost undistinguishable ripple produced by the faintest breeze upon the quiet surface of an inland lake; a pale green would now cover half the firmament from the east, while rich crimson met it from the west&#8212;then the ruddy light would concentrate itself at the zenith, while beneath it fell in folds of beauty the mild purple and green. To the east and to the west lay huge fields of luminous clouds, tinted with a bright rosy flush, wholly unlike that produced by the rising sun and if possible even more beautiful.</p>
</blockquote>
<p>And so it went around the United States and the world. The sky appeared "blood red," noted the <em>New York Herald.</em> The storm produced "a beautiful halo, and at another period it had the effect of falling from the apex in showers of nebulous matter like star-dust," reported the <em>The Hobart Town Mercury</em> from Tasmania.</p>
<p>Not all reporters welcomed these images with pleasure. "Half-past eleven. The appearance now is positively awful," wrote a horrified correspondent for the <em>San Francisco Chronicle</em> on September 5. "The red glare is over houses, streets, and fields, and the most dreadful of conflagrations could not cast a deeper hue abroad."</p>
<p>Others took a pragmatic approach to the moment. </p>
<p>"Singular as it may appear, a gentleman actually killed three birds with a gun yesterday morning about one o'clock [in the morning]," disclosed the <em>New Orleans Times Picayune</em>, "a circumstance which perhaps never had its like before. The birds were killed while the beautiful aurora borealis was at its height, and being a very early species&#8212;larks&#8212;were, no doubt, deceived by the bright appearance of everything, and came forth innocently, supposing it was day." </p>
<div class="bottom-image-credit">
<a href="http://www.geomag.bgs.ac.uk/education/carrington.html">Photograph by British Geological Survey</a>
</div>
</div>
<!-- Article Pager -->
<div class="pager">
<div class="label">Page:</div>
<ul>
<li class="selected">1</li>
<li><a href="/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars/2">2</a></li>
</ul>
<div class="next-page">
<a href="/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars/2">Next &gt;</a>
</div>
</div>
</div>
<noscript>
<img style="position: absolute; bottom: 0px; right: 0px; width: 1px; height: 1px;" src="http://arstechnica.com/dragons/brains.gif?id=55765&amp;91047084" alt="" />
</noscript>
<script type="text/javascript">
document.write('<img style="position: absolute; bottom: 0px; right: 0px; width: 1px; height: 1px;" src="http://arstechnica.com/dragons/brains.gif?id=55765&amp;' + (parseInt(Math.random()*99999999, 10)).toString() + '" alt="" />');
</script>
<!--googleoff: all-->
<div id="comments-bar" class="with-bubble">
<h2>User comments</h2>
<div class="comments-link">
<a name="comments-bar" rel="nofollow" href="/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars?comments=1#comments-bar">Click here to view the 30 comments on this story</a>
</div>
</div>
<div id="hiddencomment"></div>
<!--<div id="alert"><p><img src="http://arstechnica.com/civis/images/smilies/flail.gif" /> We're making some updates to the commenting system. We should have the kinks worked out soon.</p></div>-->
<!--googleon: all-->
<div id="links-bar">
<ul>
<li class="facebook">
<iclint src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Farstechnica.com%2Fscience%2Fnews%2F2012%2F05%2F1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:21px;" allowTransparency="true"></iclint>
</li>
<li class="gplus">
<g:plusone size="medium" href="http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars"></g:plusone>
</li>
<li class="linkedin"><script type="IN/Share" data-counter="right"></script></li>
<li><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://arst.ch/tmc" data-counturl="http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars" data-count="horizontal" data-via="arstechnica" data-related="matthewlasar:Matthew Lasar">Tweet</a></li>
<li class="reddit">
<iclint src="http://www.reddit.com/static/button/button1.html?width=120&url=http%3A%2F%2Farstechnica.com%2Fscience%2Fnews%2F2012%2F05%2F1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars&amp;title=1859%27s%20%22Great%20Auroral%20Storm%22%26%238212%3Bthe%20week%20the%20Sun%20touched%20the%20earth&amp;bgcolor=fff&amp;bordercolor=eee" width="120" height="20" scrolling="no" frameborder="0"></iclint>
</li>
<li class="share">
<a class="a2a_dd" href="http://www.addtoany.com/share_save?linkname=1859%27s%20%22Great%20Auroral%20Storm%22%26%238212%3Bthe%20week%20the%20Sun%20touched%20the%20earth&amp;linkurl=http%3A%2F%2Farstechnica.com%2Fscience%2Fnews%2F2012%2F05%2F1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars"><img src="http://static.addtoany.com/buttons/favicon.png" width="16" height="16" border="0" alt="Share/Bookmark" style="display:inline;vertical-align:middle;"/> Share/Email</a>
<script type="text/javascript">
var a2a_linkname="1859\'s \"Great Auroral Storm\"&#8212;the week the Sun touched the earth",
a2a_linkurl="http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars",
a2a_onclick=1,
a2a_show_title=1,
a2a_hide_embeds=0,
a2a_num_services=8,
a2a_color_main="989EA3",
a2a_color_border="989EA3",
a2a_color_link_text="FF5B00",
a2a_color_link_text_hover="ffffff",
a2a_track_links='ga',
a2a_prioritize= [
"digg",
"yahoo_buzz",
"stumbleupon",
"instapaper",
"slashdot",
"linkedin",
"delicious",
"google_reader",
"tumblr",
"posterous"
];
var a2a_config = a2a_config || {};
a2a_config.no_3p = 1;
</script>
<style type="text/css">#a2apage_BROWSER { display:none !important; }</style>
</li>
<li class="copypasta copy-pasta-button">Make a correction</li>
</ul>
</div>
<script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>
<!--googleoff: all-->
<div id="read-more-stories">
<h2>Read more stories</h2>
<div class="story-navigation">
<a href="/gadgets/news/2012/05/android-users-targeted-for-the-first-time-in-drive-by-download-attacks.ars" title="Read the previously published article">&lt; Older Story</a>
</div>
<!--googleoff: all-->
<script language='JavaScript'>
var OB_langJS = "http://static.arstechnica.net//public/v6/scripts/outbrain.lang_en_ars.js",OBITm = '1306449288604',OB_raterMode = 'singlethumb',OB_recMode = 'strip',OutbrainPermaLink='http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars';
if (typeof(OB_Script)!='undefined' ){OutbrainStart();}else{var OB_Script = true,str = unescape("%3Cscript src=\'http://widgets.outbrain.com/OutbrainRater.js\' type=\'text/javascript\'%3E%3C/script%3E");document.write(str);}
</script>
<!--googleon: all-->
</div>
<!--googleon: all-->
</div>
</div>
<!--googleoff: all-->
<div id="sidebar">
<div id="article-links" class="with-divider" style="display:none;">
<ul>
<li class="enlarge-text"><a href="#">Increase text size</a></li>
<li class="shrink-text"><a href="#">Reduce text size</a></li>
<li class="print"><a href="#">Print this story</a></li>
<li class="comment"><a href="/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars?comments=1#comments-bar#comments-bar">Leave a comment (30)</a></li>
<li class="copy-pasta-button edit-suggestion" style="display: none;"><a href="#">Make a correction</a></li>
<li class="shorturl"><a rel="nofollow" href="http://arst.ch/tmc">http://arst.ch/tmc</a></li>
</ul>
<div class="premier">Premier features ( <a href="/subscriptions/">learn more</a> ) :</div>
<ul>
<li class="single-page"><a href="/subscriptions/" class="nonsub">View on single page</a></li>
<li class="configure"><a href="/subscriptions/">Configure these features</a></li>
</ul>
</div>
<div id="tile-top" class="">
<noscript>
<div id="help-by-subscribing">
<a href="/gadgets/news/2012/05/android-users-targeted-for-the-first-time-in-drive-by-download-attacks.ars/2"><img src="/gadgets/news/2012/05/android-users-targeted-for-the-first-time-in-drive-by-download-attacks.ars/4" alt="Please subscribe" /></a></div>
</noscript>
<script type="text/javascript">
try {
var ppanel = cnp.ad.create(cnp.ad.refreshable, false);
ppanel.addParameterString('kw=top;kw=1859s-great-auroral-stormthe-week-the-sun-touched-the-earth;kw=05;kw=2012;kw=news;kw=science;');
ppanel.addParameter({'sz':'300x250'});
ppanel.load();
} catch(e) {}
</script>
</div>
<div id="journals-box" class="with-divider">
<h2 class="title">Latest Top Stories</h2>
<ul class="category">
<li class="all selected">
<span class="tab-inner">
<a href="/" title="All">All</a>
</span>
</li>
<li class="apple">
<span class="tab-inner">
<a href="/apple/" title="Apple">Apple</a>
</span>
</li>
<li class="gaming">
<span class="tab-inner">
<a href="/gaming/" title="Gaming">Gaming</a>
</span>
</li>
<li class="microsoft">
<span class="tab-inner">
<a href="/microsoft/" title="Microsoft">Microsoft</a>
</span>
</li>
<li class="gadgets">
<span class="tab-inner">
<a href="/gadgets/" title="Gadgets">Gadgets</a>
</span>
</li>
<li class="open-source">
<span class="tab-inner">
<a href="/open-source/" title="Open Source">Open Source</a>
</span>
</li>
<li class="business">
<span class="tab-inner">
<a href="/business/" title="Business">Business</a>
</span>
</li>
<li class="science">
<span class="tab-inner">
<a href="/science/" title="Science">Science</a>
</span>
</li>
<li class="tech-policy">
<span class="tab-inner">
<a href="/tech-policy/" title="Tech Policy">Tech Policy</a>
</span>
</li>
<li class="staff">
<span class="tab-inner">
<a href="/staff/" title="Staff">Staff</a>
</span>
</li>
</ul>
<ul class="stories">
<li id="journal-box-0" class="science">
<a href="/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars?clicked=related_right">1859's "Great Auroral Storm"&#8212;the week the Sun touched the earth</a>
</li>
<li id="journal-box-1" class="gadgets">
<a href="/gadgets/news/2012/05/android-users-targeted-for-the-first-time-in-drive-by-download-attacks.ars?clicked=related_right">Android users targeted in drive-by download attacks </a>
</li>
<li id="journal-box-2" class="getting-it-done">
<a href="/getting-it-done/2012/05/google-beefs-up-apps-scripts-for-docs.ars?clicked=related_right">Google beefs up Apps Scripts for Docs</a>
</li>
<li id="journal-box-3" class="tech-policy">
<a href="/tech-policy/news/2012/05/furious-judge-decries-blizzard-of-copyright-troll-lawsuits.ars?clicked=related_right">Furious judge decries "blizzard" of copyright troll lawsuits</a>
</li>
<li id="journal-box-4" class="microsoft">
<a href="/microsoft/news/2012/05/windows-8-to-integrate-cloud-services-ditch-windows-live-branding.ars?clicked=related_right">Windows 8 to integrate cloud services, ditch Windows Live branding</a>
</li>
<li id="journal-box-5" class="gaming">
<a href="/gaming/news/2012/05/virtual-shooting-games-may-improve-accuracy-but-wont-make-you-a-sniper.ars?clicked=related_right">Virtual shooting games may improve real-world accuracy, won't make you a sniper</a>
</li>
<li id="journal-box-6" class="science">
<a href="/science/news/2012/05/sequestration-meets-extraction-us-swaps-carbon-dioxide-for-methane-under-the-sea.ars?clicked=related_right">Dept. of Energy extracts hydrocarbons from sea, sequesters CO2 in Davy Jones' locker</a>
</li>
<li id="journal-box-7" class="business">
<a href="/business/news/2012/05/html5-based-meego-successor-tizen-hits-10-milestone.ars?clicked=related_right">HTML5-based MeeGo successor Tizen hits 1.0 milestone</a>
</li>
<li id="journal-box-8" class="tech-policy">
<a href="/tech-policy/news/2012/05/eus-top-court-apis-cant-be-copyrighted-would-monopolise-ideas.ars?clicked=related_right">EU's top court: APIs can't be copyrighted, would "monopolise ideas"</a>
</li>
<li id="journal-box-9" class="science">
<a href="/science/news/2012/05/usdas-wildlife-services-program-kills-50000-harmless-animals.ars?clicked=related_right">USDA's Wildlife Services program reportedly kills 50,000 harmless animals</a>
</li>
<li id="journal-box-10" class="business">
<a href="/business/news/2012/05/amazon-funding-original-comedy-childrens-television-for-instant-streaming.ars?clicked=related_right">Amazon wants original comedy, children's television ideas for Instant streaming</a>
</li>
<li id="journal-box-11" class="apple">
<a href="/apple/guides/2012/05/creating-videos-with-51-audio-for-the-apple-tv-mac-and-ios.ars?clicked=related_right">Creating videos with 5.1 audio for the Apple TV, Mac, and iOS</a>
</li>
<li id="journal-box-12" class="business">
<a href="/business/news/2012/05/european-privacy-police-say-google-duped-them-over-street-view.ars?clicked=related_right">European privacy police say Google "duped" them over Street View </a>
</li>
<li id="journal-box-13" class="science">
<a href="/science/news/2012/05/a-burp-of-light-from-a-black-hole-reveals-that-it-ate-a-star.ars?clicked=related_right">A burp of light from a black hole reveals that it ate a star</a>
</li>
<li id="journal-box-14" class="science">
<a href="/science/news/2012/05/research-finally-published-showing-how-bird-flu-virus-can-spread-among-mammals.ars?clicked=related_right">Research finally published showing how bird flu virus can spread among mammals</a>
</li>
</ul>
</div>
<div class="with-divider" id="fb">
<iclint src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Ffacebook.com%2Farstechnica&amp;width=300&amp;colorscheme=light&amp;show_faces=false&amp;stream=false&amp;header=false&amp;height=62&amp;border_color=%23FFFFFF" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:62px;" allowTransparency="true"></iclint>
<iclint src="http://www.facebook.com/plugins/activity.php?site=arstechnica.com&amp;width=300&amp;height=370&amp;header=false&amp;colorscheme=light&amp;recommendations=false&amp;border_color=%23FFFFFF" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:370px;" allowTransparency="true"></iclint>
<p><a href="#" class="anonymous">Disable Facebook on Ars</a></p>
</div>
<div id="tile-bottom" class="">
<noscript>
<div id="help-by-subscribing">
<a href="/gadgets/news/2012/05/android-users-targeted-for-the-first-time-in-drive-by-download-attacks.ars/2"><img src="/gadgets/news/2012/05/android-users-targeted-for-the-first-time-in-drive-by-download-attacks.ars/4" alt="Please subscribe" /></a></div>
</noscript>
<script type="text/javascript">
try {
var ppanel = cnp.ad.create(cnp.ad.refreshable, false);
ppanel.addParameterString('kw=bottom;kw=1859s-great-auroral-stormthe-week-the-sun-touched-the-earth;kw=05;kw=2012;kw=news;kw=science;');
ppanel.addParameter({'sz':'300x250'});
ppanel.load();
} catch(e) {}
</script>
</div>
<div id="jobs-ars"><a href="http://jobs.arstechnica.com/"><img src="http://static.arstechnica.com//public/v6/styles/dark/images/sidebar/monster-job-board-300x250b.jpg" alt="Ars Job Board Powered by Monster" /></a></div>
</div>
<!--googleon: all-->
</div>
<div id="footer">
<div id="slogan">Serving the technologist for <span id="decades">1</span> &#x00d7; 10<sup>-1</sup> centuries</div>
<iframe src="http://static.arstechnica.net//public/v6/footer.html?1335816272" frameborder="0" scrolling="no" width="1000" height="350"></iframe>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31997-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
var page_class = 'individual',
site_root = "",
site_root_rel = '/',
discussion_url = "",
entry_author = {
"matthew lasar":true,
"matthew lasar":true,
"":true
},
entry_id = 55765,
fp_layout = 'normal',
syntaxhighlighter = "http://static.arstechnica.com/public/full/scripts/syntaxhighlighter.js",
new_comments = true,
disable_fb = 'false';
</script>
<script src="http://static.arstechnica.net//public/v6/scripts/site.min.js?1335816272" type="text/javascript" charset="utf-8"></script>
<noscript>
<img src="http://b.scorecardresearch.com/b?c1=2&c2=6035094&c3=&c4=&c5=&c6=&c15=&cv=1.3&cj=1" style="position:absolute; bottom: 0px; right:0px;"
width="1" height="1" alt="" />
</noscript>
<span style="display: none" id="ArsTechnicaNews" class="hslice">
<span style="display: none" class="entry-title">Ars Technica News</span>
<a style="display: none" href="http://www.ieaddons.com/en/ie8slice/Content.ashx?id=330" rel="entry-content"></a>
</span>
<script type="text/javascript">
var s_account="conde-arstechnica";
var s_linkInternalFilters="javascript:,arstechnica.com";
var s_trackingServer="stats2.arstechnica.com";
var s_trackingServerSecure='sstats.arstechnica.com';
</script>
<script type="text/javascript" src="http://static.arstechnica.net/public/shared/omniture/s_code.js"></script>
<script type="text/javascript">
s.pageName = "http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars";
s.prop1 = "";
s.prop2 = "";
s.prop5 = "blog";
s.events = "";
s.prop6 = "science"
s.prop7 = "science/news"
s.prop8 = "science/news/2012"
s.prop9 = "science/news/2012/05"
s.prop3 = "Science";
s.hier1 = "science,news,2012,05";
var s_code=s.t();
if(s_code) document.write(s_code);
</script>
<script type="text/javascript"> if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')</script>
<noscript><a href="http://www.omniture.com" title="Web Analytics"><img src="http://condenast.112.2o7.net/b/ss/condenet-dev/1/H.15.1--NS/0" height="1" width="1" border="0" alt="" /></a></noscript>
<!-- START Parse.ly Include: Standard -->
<div id="parsely-root" style="display: none">
<a id="parsely-cfg" data-parsely-site="arstechnica.com"
href="http://parsely.com">Powered by the Parse.ly Publisher Platform (P3).</a>
</div>
<script>
(function(s, p, d) {
var h=d.location.protocol, i=p+"-"+s,
e=d.getElementById(i), r=d.getElementById(p+"-root");
if (e) return;
e = d.createElement(s); e.id = i; e.async = true;
e.src = h+"//static.parsely.com/p.js"; r.appendChild(e);
})("script", "parsely", document);
</script>
<!-- END Parse.ly Include -->
<script type='text/javascript'>
var _sf_async_config={};
/** CONFIGURATION START **/
_sf_async_config.uid = 27113;
_sf_async_config.domain = 'arstechnica.com';
_sf_async_config.sections = 'Nobel Intent'; //CHANGE THIS
_sf_async_config.authors = 'Matthew Lasar'; //CHANGE THIS
_sf_async_config.path = "http://arstechnica.com/science/news/2012/05/1859s-great-auroral-stormthe-week-the-sun-touched-the-earth.ars";
_sf_async_config.title = '1859\'s \"Great Auroral Storm\"&#8212;the week the Sun touched the earth';
/** CONFIGURATION END **/
(function(){
function loadChartbeat() {
window._sf_endpt=(new Date()).getTime();
var e = document.createElement('script');
e.setAttribute('language', 'javascript');
e.setAttribute('type', 'text/javascript');
e.setAttribute('src',
(('https:' == document.location.protocol) ? 'https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/' : 'http://static.chartbeat.com/') +
'js/chartbeat.js');
document.body.appendChild(e);
}
var oldonload = window.onload;
window.onload = (typeof window.onload != 'function') ?
loadChartbeat : function() { oldonload(); loadChartbeat(); };
})();
</script>
</body>
</html>

@ -0,0 +1,855 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<title>Django | Writing your first Django app, part 1 | Django documentation</title>
<meta name="ROBOTS" content="ALL" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Copyright" content="Django Software Foundation" />
<meta name="keywords" content="Python, Django, framework, open-source" />
<meta name="description" content="Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design." />
<link href="https://www.djangoproject.com/m/css/base.css" rel="stylesheet" type="text/css" media="screen" />
<link href="https://www.djangoproject.com/m/css/print.css" rel="stylesheet" type="text/css" media="print" />
<link rel="stylesheet" href="https://www.djangoproject.com/m/css/docs/docs.css" type="text/css" />
<link rel="stylesheet" href="https://www.djangoproject.com/m/css/pygments.css" type="text/css" />
</head>
<body id="documentation" class="default">
<div id="container">
<div id="header">
<h1 id="logo"><a href="https://www.djangoproject.com/"><img src="https://www.djangoproject.com/m/img/site/hdr_logo.gif" alt="Django" /></a></h1>
<ul id="nav-global">
<li id="nav-homepage"><a href="https://www.djangoproject.com/">Home</a></li>
<li id="nav-download"><a href="https://www.djangoproject.com/download/">Download</a></li>
<li id="nav-documentation"><a href="https://docs.djangoproject.com/">Documentation</a></li>
<li id="nav-weblog"><a href="https://www.djangoproject.com/weblog/">Weblog</a></li>
<li id="nav-community"><a href="https://www.djangoproject.com/community/">Community</a></li>
<li id="nav-code"><a href="https://code.djangoproject.com/">Code</a></li>
</ul>
</div>
<!-- END Header -->
<div id="billboard">
<h2><a href="/en/1.4/">Django documentation</a></h2>
</div>
<div id="columnwrap">
<div id="content-main">
<ul id="doc-versions">
<li class="other">
<a href="/en/1.0/intro/tutorial01/">1.0</a></li>
<li class="other">
<a href="/en/1.1/intro/tutorial01/">1.1</a></li>
<li class="other">
<a href="/en/1.2/intro/tutorial01/">1.2</a></li>
<li class="other">
<a href="/en/1.3/intro/tutorial01/">1.3</a></li>
<li class="other">
<a href="/en/dev/intro/tutorial01/">dev</a></li>
<li class="current"
title="This document describes Django 1.4. Click on the links on the left to see other versions.">
<span>Documentation version:
<strong>1.4</strong>
</span>
</li>
</ul>
<div class="section" id="s-writing-your-first-django-app-part-1">
<span id="writing-your-first-django-app-part-1"></span><h1>Writing your first Django app, part 1<a class="headerlink" href="#writing-your-first-django-app-part-1" title="Permalink to this headline"></a></h1>
<p>Let&#8217;s learn by example.</p>
<p>Throughout this tutorial, we&#8217;ll walk you through the creation of a basic
poll application.</p>
<p>It&#8217;ll consist of two parts:</p>
<ul class="simple">
<li>A public site that lets people view polls and vote in them.</li>
<li>An admin site that lets you add, change and delete polls.</li>
</ul>
<p>We&#8217;ll assume you have <a class="reference internal" href="../install/"><em>Django installed</em></a> already. You can
tell Django is installed by running the Python interactive interpreter and
typing <tt class="docutils literal"><span class="pre">import</span> <span class="pre">django</span></tt>. If that command runs successfully, with no errors,
Django is installed.</p>
<div class="admonition-where-to-get-help admonition ">
<p class="first admonition-title">Where to get help:</p>
<p class="last">If you&#8217;re having trouble going through this tutorial, please post a message
to <a class="reference external" href="http://groups.google.com/group/django-users">django-users</a> or drop by <a class="reference external" href="irc://irc.freenode.net/django">#django on irc.freenode.net</a> to chat
with other Django users who might be able to help.</p>
</div>
<div class="section" id="s-creating-a-project">
<span id="creating-a-project"></span><h2>Creating a project<a class="headerlink" href="#creating-a-project" title="Permalink to this headline"></a></h2>
<p>If this is your first time using Django, you&#8217;ll have to take care of some
initial setup. Namely, you&#8217;ll need to auto-generate some code that establishes a
Django <a class="reference internal" href="../../glossary/#term-project"><em class="xref std std-term">project</em></a> &#8211; a collection of settings for an instance of Django,
including database configuration, Django-specific options and
application-specific settings.</p>
<p>From the command line, <tt class="docutils literal"><span class="pre">cd</span></tt> into a directory where you&#8217;d like to store your
code, then run the following command:</p>
<div class="highlight-bash"><div class="highlight"><pre>django-admin.py startproject mysite
</pre></div>
</div>
<p>This will create a <tt class="docutils literal"><span class="pre">mysite</span></tt> directory in your current directory.</p>
<div class="admonition-script-name-may-differ-in-distribution-packages admonition ">
<p class="first admonition-title">Script name may differ in distribution packages</p>
<p class="last">If you installed Django using a Linux distribution's package manager
(e.g. apt-get or yum) <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> may have been renamed to
<tt class="docutils literal"><span class="pre">django-admin</span></tt>. You may continue through this documentation by omitting
<tt class="docutils literal"><span class="pre">.py</span></tt> from each command.</p>
</div>
<div class="admonition-mac-os-x-permissions admonition ">
<p class="first admonition-title">Mac OS X permissions</p>
<p class="last">If you're using Mac OS X, you may see the message &quot;permission denied&quot; when
you try to run <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">startproject</span></tt>. This is because, on
Unix-based systems like OS X, a file must be marked as &quot;executable&quot; before it
can be run as a program. To do this, open Terminal.app and navigate (using
the <tt class="docutils literal"><span class="pre">cd</span></tt> command) to the directory where <a class="reference internal" href="../../ref/django-admin/"><em>django-admin.py</em></a> is installed, then run the command
<tt class="docutils literal"><span class="pre">sudo</span> <span class="pre">chmod</span> <span class="pre">+x</span> <span class="pre">django-admin.py</span></tt>.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You'll need to avoid naming projects after built-in Python or Django
components. In particular, this means you should avoid using names like
<tt class="docutils literal"><span class="pre">django</span></tt> (which will conflict with Django itself) or <tt class="docutils literal"><span class="pre">test</span></tt> (which
conflicts with a built-in Python package).</p>
</div>
<p><a class="reference internal" href="../../ref/django-admin/"><em>django-admin.py</em></a> should be on your system path if you
installed Django via <tt class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span></tt>. If it's not on your path, you can find
it in <tt class="docutils literal"><span class="pre">site-packages/django/bin</span></tt>, where <tt class="docutils literal"><span class="pre">site-packages</span></tt> is a directory
within your Python installation. Consider symlinking to <a class="reference internal" href="../../ref/django-admin/"><em>django-admin.py</em></a> from some place on your path, such as
<tt class="file docutils literal"><span class="pre">/usr/local/bin</span></tt>.</p>
<div class="admonition-where-should-this-code-live admonition ">
<p class="first admonition-title">Where should this code live?</p>
<p>If your background is in PHP, you're probably used to putting code under the
Web server's document root (in a place such as <tt class="docutils literal"><span class="pre">/var/www</span></tt>). With Django,
you don't do that. It's not a good idea to put any of this Python code
within your Web server's document root, because it risks the possibility
that people may be able to view your code over the Web. That's not good for
security.</p>
<p class="last">Put your code in some directory <strong>outside</strong> of the document root, such as
<tt class="file docutils literal"><span class="pre">/home/mycode</span></tt>.</p>
</div>
<p>Let's look at what <a class="reference internal" href="../../ref/django-admin/#django-admin-startproject"><tt class="xref std std-djadmin docutils literal"><span class="pre">startproject</span></tt></a> created:</p>
<div class="highlight-python"><pre>mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py</pre>
</div>
<div class="admonition-doesn-t-match-what-you-see admonition ">
<p class="first admonition-title">Doesn't match what you see?</p>
<p class="last">The default project layout recently changed. If you're seeing a &quot;flat&quot;
layout (with no inner <tt class="file docutils literal"><span class="pre">mysite/</span></tt> directory), you're probably using
a version of Django that doesn't match this tutorial version. You'll
want to either switch to the older tutorial or the newer Django version.</p>
</div>
<p>These files are:</p>
<ul class="simple">
<li>The outer <tt class="file docutils literal"><span class="pre">mysite/</span></tt> directory is just a container for your
project. Its name doesn't matter to Django; you can rename it to anything
you like.</li>
<li><tt class="file docutils literal"><span class="pre">manage.py</span></tt>: A command-line utility that lets you interact with this
Django project in various ways. You can read all the details about
<tt class="file docutils literal"><span class="pre">manage.py</span></tt> in <a class="reference internal" href="../../ref/django-admin/"><em>django-admin.py and manage.py</em></a>.</li>
<li>The inner <tt class="file docutils literal"><span class="pre">mysite/</span></tt> directory is the actual Python package for your
project. Its name is the Python package name you'll need to use to import
anything inside it (e.g. <tt class="docutils literal"><span class="pre">import</span> <span class="pre">mysite.settings</span></tt>).</li>
<li><tt class="file docutils literal"><span class="pre">mysite/__init__.py</span></tt>: An empty file that tells Python that this
directory should be considered a Python package. (Read <a class="reference external" href="http://docs.python.org/tutorial/modules.html#packages">more about
packages</a> in the official Python docs if you're a Python beginner.)</li>
<li><tt class="file docutils literal"><span class="pre">mysite/settings.py</span></tt>: Settings/configuration for this Django
project. <a class="reference internal" href="../../topics/settings/"><em>Django settings</em></a> will tell you all about how settings
work.</li>
<li><tt class="file docutils literal"><span class="pre">mysite/urls.py</span></tt>: The URL declarations for this Django project; a
&quot;table of contents&quot; of your Django-powered site. You can read more about
URLs in <a class="reference internal" href="../../topics/http/urls/"><em>URL dispatcher</em></a>.</li>
<li><tt class="file docutils literal"><span class="pre">mysite/wsgi.py</span></tt>: An entry-point for WSGI-compatible webservers to
serve your project. See <a class="reference internal" href="../../howto/deployment/wsgi/"><em>How to deploy with WSGI</em></a> for more details.</li>
</ul>
<div class="section" id="s-the-development-server">
<span id="the-development-server"></span><h3>The development server<a class="headerlink" href="#the-development-server" title="Permalink to this headline"></a></h3>
<p>Let's verify this worked. Change into the outer <tt class="file docutils literal"><span class="pre">mysite</span></tt> directory, if
you haven't already, and run the command <tt class="docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">runserver</span></tt>. You'll
see the following output on the command line:</p>
<div class="highlight-python"><pre>Validating models...
0 errors found.
Django version 1.4, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.</pre>
</div>
<p>You've started the 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.</p>
<p>Now's a good time to note: DON'T use this server in anything resembling a
production environment. It's intended only for use while developing. (We're in
the business of making Web frameworks, not Web servers.)</p>
<p>Now that the server's running, visit <a class="reference external" href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a> with your Web
browser. You'll see a &quot;Welcome to Django&quot; page, in pleasant, light-blue pastel.
It worked!</p>
<div class="admonition-changing-the-port admonition ">
<p class="first admonition-title">Changing the port</p>
<p>By default, the <a class="reference internal" href="../../ref/django-admin/#django-admin-runserver"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></a> command starts the development server
on the internal IP at port 8000.</p>
<p>If you want to change the server's port, pass
it as a command-line argument. For instance, this command starts the server
on port 8080:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py runserver 8080
</pre></div>
</div>
<p>If you want to change the server's IP, pass it along with the port. So to
listen on all public IPs (useful if you want to show off your work on other
computers), use:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py runserver 0.0.0.0:8000
</pre></div>
</div>
<p class="last">Full docs for the development server can be found in the
<a class="reference internal" href="../../ref/django-admin/#django-admin-runserver"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></a> reference.</p>
</div>
</div>
<div class="section" id="s-database-setup">
<span id="database-setup"></span><h3>Database setup<a class="headerlink" href="#database-setup" title="Permalink to this headline"></a></h3>
<p>Now, edit <tt class="file docutils literal"><span class="pre">mysite/settings.py</span></tt>. It's a normal Python module with
module-level variables representing Django settings. Change the
following keys in the <a class="reference internal" href="../../ref/settings/#std:setting-DATABASES"><tt class="xref std std-setting docutils literal"><span class="pre">DATABASES</span></tt></a> <tt class="docutils literal"><span class="pre">'default'</span></tt> item to match
your database connection settings.</p>
<ul>
<li><p class="first"><a class="reference internal" href="../../ref/settings/#std:setting-DATABASE-ENGINE"><tt class="xref std std-setting docutils literal"><span class="pre">ENGINE</span></tt></a> -- Either
<tt class="docutils literal"><span class="pre">'django.db.backends.postgresql_psycopg2'</span></tt>,
<tt class="docutils literal"><span class="pre">'django.db.backends.mysql'</span></tt>, <tt class="docutils literal"><span class="pre">'django.db.backends.sqlite3'</span></tt> or
<tt class="docutils literal"><span class="pre">'django.db.backends.oracle'</span></tt>. Other backends are <a class="reference internal" href="../../ref/settings/#std:setting-DATABASE-ENGINE"><tt class="xref std std-setting docutils literal"><span class="pre">also</span> <span class="pre">available</span></tt></a>.</p>
</li>
<li><p class="first"><a class="reference internal" href="../../ref/settings/#std:setting-NAME"><tt class="xref std std-setting docutils literal"><span class="pre">NAME</span></tt></a> -- The name of your database. If you're using
SQLite, the database will be a file on your computer; in that
case, <a class="reference internal" href="../../ref/settings/#std:setting-NAME"><tt class="xref std std-setting docutils literal"><span class="pre">NAME</span></tt></a> should be the full absolute path,
including filename, of that file. If the file doesn't exist, it
will automatically be created when you synchronize the database
for the first time (see below).</p>
<p>When specifying the path, always use forward slashes, even on
Windows (e.g. <tt class="docutils literal"><span class="pre">C:/homes/user/mysite/sqlite3.db</span></tt>).</p>
</li>
<li><p class="first"><a class="reference internal" href="../../ref/settings/#std:setting-USER"><tt class="xref std std-setting docutils literal"><span class="pre">USER</span></tt></a> -- Your database username (not used for SQLite).</p>
</li>
<li><p class="first"><a class="reference internal" href="../../ref/settings/#std:setting-PASSWORD"><tt class="xref std std-setting docutils literal"><span class="pre">PASSWORD</span></tt></a> -- Your database password (not used for
SQLite).</p>
</li>
<li><p class="first"><a class="reference internal" href="../../ref/settings/#std:setting-HOST"><tt class="xref std std-setting docutils literal"><span class="pre">HOST</span></tt></a> -- The host your database is on. Leave this as
an empty string if your database server is on the same physical
machine (not used for SQLite).</p>
</li>
</ul>
<p>If you're new to databases, we recommend simply using SQLite by setting
<tt class="xref std std-setting docutils literal"><span class="pre">ENGINE</span></tt> to <tt class="docutils literal"><span class="pre">'django.db.backends.sqlite3'</span></tt> and <a class="reference internal" href="../../ref/settings/#std:setting-NAME"><tt class="xref std std-setting docutils literal"><span class="pre">NAME</span></tt></a> to
the place where you'd like to store the database. SQLite is included in Python,
so you won't need to install anything else to support your database.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>If you're using PostgreSQL or MySQL, make sure you've created a database by
this point. Do that with &quot;<tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">DATABASE</span> <span class="pre">database_name;</span></tt>&quot; within your
database's interactive prompt.</p>
<p class="last">If you're using SQLite, you don't need to create anything beforehand - the
database file will be created automatically when it is needed.</p>
</div>
<p>While you're editing <tt class="file docutils literal"><span class="pre">settings.py</span></tt>, set <a class="reference internal" href="../../ref/settings/#std:setting-TIME_ZONE"><tt class="xref std std-setting docutils literal"><span class="pre">TIME_ZONE</span></tt></a> to your
time zone. The default value is the Central time zone in the U.S. (Chicago).</p>
<p>Also, note the <a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> setting toward the bottom of
the file. That holds the names of all Django applications that are
activated in this Django instance. Apps can be used in multiple projects, and
you can package and distribute them for use by others in their projects.</p>
<p>By default, <a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> contains the following apps, all of which
come with Django:</p>
<ul class="simple">
<li><a class="reference internal" href="../../topics/auth/#module-django.contrib.auth" title="django.contrib.auth: Django's authentication framework."><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.auth</span></tt></a> -- An authentication system.</li>
<li><a class="reference internal" href="../../ref/contrib/contenttypes/#module-django.contrib.contenttypes" title="django.contrib.contenttypes: Provides generic interface to installed models."><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.contenttypes</span></tt></a> -- A framework for content types.</li>
<li><a class="reference internal" href="../../topics/http/sessions/#module-django.contrib.sessions" title="django.contrib.sessions: Provides session management for Django projects."><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.sessions</span></tt></a> -- A session framework.</li>
<li><a class="reference internal" href="../../ref/contrib/sites/#module-django.contrib.sites" title="django.contrib.sites: Lets you operate multiple Web sites from the same database and Django project"><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.sites</span></tt></a> -- A framework for managing multiple sites
with one Django installation.</li>
<li><a class="reference internal" href="../../ref/contrib/messages/#module-django.contrib.messages" title="django.contrib.messages: Provides cookie- and session-based temporary message storage."><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.messages</span></tt></a> -- A messaging framework.</li>
<li><a class="reference internal" href="../../ref/contrib/staticfiles/#module-django.contrib.staticfiles" title="django.contrib.staticfiles: An app for handling static files."><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.staticfiles</span></tt></a> -- A framework for managing
static files.</li>
</ul>
<p>These applications are included by default as a convenience for the common case.</p>
<p>Each of these applications makes use of at least one database table, though,
so we need to create the tables in the database before we can use them. To do
that, run the following command:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py syncdb
</pre></div>
</div>
<p>The <a class="reference internal" href="../../ref/django-admin/#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a> command looks at the <a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> setting and
creates any necessary database tables according to the database settings in your
<tt class="file docutils literal"><span class="pre">settings.py</span></tt> file. You'll see a message for each database table it
creates, and you'll get a prompt asking you if you'd like to create a superuser
account for the authentication system. Go ahead and do that.</p>
<p>If you're interested, run the command-line client for your database and type
<tt class="docutils literal"><span class="pre">\dt</span></tt> (PostgreSQL), <tt class="docutils literal"><span class="pre">SHOW</span> <span class="pre">TABLES;</span></tt> (MySQL), or <tt class="docutils literal"><span class="pre">.schema</span></tt> (SQLite) to
display the tables Django created.</p>
<div class="admonition-for-the-minimalists admonition ">
<p class="first admonition-title">For the minimalists</p>
<p class="last">Like we said above, the default applications are included for the common
case, but not everybody needs them. If you don't need any or all of them,
feel free to comment-out or delete the appropriate line(s) from
<a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> before running <a class="reference internal" href="../../ref/django-admin/#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a>. The
<a class="reference internal" href="../../ref/django-admin/#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a> command will only create tables for apps in
<a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a>.</p>
</div>
</div>
</div>
<div class="section" id="s-creating-models">
<span id="s-id3"></span><span id="creating-models"></span><span id="id3"></span><h2>Creating models<a class="headerlink" href="#creating-models" title="Permalink to this headline"></a></h2>
<p>Now that your environment -- a &quot;project&quot; -- is set up, you're set to start
doing work.</p>
<p>Each application you write in Django consists of a Python package, somewhere
on your <a class="reference external" href="http://docs.python.org/tutorial/modules.html#the-module-search-path">Python path</a>, that follows a certain convention. Django comes with a
utility that automatically generates the basic directory structure of an app,
so you can focus on writing code rather than creating directories.</p>
<div class="admonition-projects-vs-apps admonition ">
<p class="first admonition-title">Projects vs. apps</p>
<p class="last">What's the difference between a project and an app? An app is a Web
application that does something -- e.g., a Weblog system, a database of
public records or a simple poll app. A project is a collection of
configuration and apps for a particular Web site. A project can contain
multiple apps. An app can be in multiple projects.</p>
</div>
<p>Your apps can live anywhere on your <a class="reference external" href="http://docs.python.org/tutorial/modules.html#the-module-search-path">Python path</a>. In this tutorial, we'll
create our poll app right next to your <tt class="file docutils literal"><span class="pre">manage.py</span></tt> file so that it can be
imported as its own top-level module, rather than a submodule of <tt class="docutils literal"><span class="pre">mysite</span></tt>.</p>
<p>To create your app, make sure you're in the same directory as <tt class="file docutils literal"><span class="pre">manage.py</span></tt>
and type this command:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py startapp polls
</pre></div>
</div>
<p>That'll create a directory <tt class="file docutils literal"><span class="pre">polls</span></tt>, which is laid out like this:</p>
<div class="highlight-python"><pre>polls/
__init__.py
models.py
tests.py
views.py</pre>
</div>
<p>This directory structure will house the poll application.</p>
<p>The first step in writing a database Web app in Django is to define your models
-- essentially, your database layout, with additional metadata.</p>
<div class="admonition-philosophy admonition ">
<p class="first admonition-title">Philosophy</p>
<p class="last">A model is the single, definitive source of data about your data. It contains
the essential fields and behaviors of the data you're storing. Django follows
the <a class="reference internal" href="../../misc/design-philosophies/#dry"><em>DRY Principle</em></a>. The goal is to define your data model in one
place and automatically derive things from it.</p>
</div>
<p>In our simple poll app, we'll create two models: polls and choices. A poll has
a question and a publication date. A choice has two fields: the text of the
choice and a vote tally. Each choice is associated with a poll.</p>
<p>These concepts are represented by simple Python classes. Edit the
<tt class="file docutils literal"><span class="pre">polls/models.py</span></tt> file so it looks like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.db</span> <span class="kn">import</span> <span class="n">models</span>
<span class="k">class</span> <span class="nc">Poll</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="n">question</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">200</span><span class="p">)</span>
<span class="n">pub_date</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">DateTimeField</span><span class="p">(</span><span class="s">&#39;date published&#39;</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">Choice</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="n">poll</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="n">Poll</span><span class="p">)</span>
<span class="n">choice</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">200</span><span class="p">)</span>
<span class="n">votes</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">IntegerField</span><span class="p">()</span>
</pre></div>
</div>
<p>The code is straightforward. Each model is represented by a class that
subclasses <a class="reference internal" href="../../ref/models/instances/#django.db.models.Model" title="django.db.models.Model"><tt class="xref py py-class docutils literal"><span class="pre">django.db.models.Model</span></tt></a>. Each model has a number of class
variables, each of which represents a database field in the model.</p>
<p>Each field is represented by an instance of a <a class="reference internal" href="../../howto/custom-model-fields/#django.db.models.Field" title="django.db.models.Field"><tt class="xref py py-class docutils literal"><span class="pre">Field</span></tt></a>
class -- e.g., <a class="reference internal" href="../../ref/models/fields/#django.db.models.CharField" title="django.db.models.CharField"><tt class="xref py py-class docutils literal"><span class="pre">CharField</span></tt></a> for character fields and
<a class="reference internal" href="../../ref/models/fields/#django.db.models.DateTimeField" title="django.db.models.DateTimeField"><tt class="xref py py-class docutils literal"><span class="pre">DateTimeField</span></tt></a> for datetimes. This tells Django what
type of data each field holds.</p>
<p>The name of each <a class="reference internal" href="../../howto/custom-model-fields/#django.db.models.Field" title="django.db.models.Field"><tt class="xref py py-class docutils literal"><span class="pre">Field</span></tt></a> instance (e.g. <tt class="docutils literal"><span class="pre">question</span></tt> or
<tt class="docutils literal"><span class="pre">pub_date</span></tt> ) is the field's name, in machine-friendly format. You'll use this
value in your Python code, and your database will use it as the column name.</p>
<p>You can use an optional first positional argument to a
<a class="reference internal" href="../../howto/custom-model-fields/#django.db.models.Field" title="django.db.models.Field"><tt class="xref py py-class docutils literal"><span class="pre">Field</span></tt></a> to designate a human-readable name. That's used
in a couple of introspective parts of Django, and it doubles as documentation.
If this field isn't provided, Django will use the machine-readable name. In this
example, we've only defined a human-readable name for <tt class="docutils literal"><span class="pre">Poll.pub_date</span></tt>. For all
other fields in this model, the field's machine-readable name will suffice as
its human-readable name.</p>
<p>Some <a class="reference internal" href="../../howto/custom-model-fields/#django.db.models.Field" title="django.db.models.Field"><tt class="xref py py-class docutils literal"><span class="pre">Field</span></tt></a> classes have required elements.
<a class="reference internal" href="../../ref/models/fields/#django.db.models.CharField" title="django.db.models.CharField"><tt class="xref py py-class docutils literal"><span class="pre">CharField</span></tt></a>, for example, requires that you give it a
<tt class="xref py py-attr docutils literal"><span class="pre">max_length</span></tt>. That's used not only in the database
schema, but in validation, as we'll soon see.</p>
<p>Finally, note a relationship is defined, using
<a class="reference internal" href="../../ref/models/fields/#django.db.models.ForeignKey" title="django.db.models.ForeignKey"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKey</span></tt></a>. That tells Django each Choice is related
to a single Poll. Django supports all the common database relationships:
many-to-ones, many-to-manys and one-to-ones.</p>
</div>
<div class="section" id="s-activating-models">
<span id="activating-models"></span><h2>Activating models<a class="headerlink" href="#activating-models" title="Permalink to this headline"></a></h2>
<p>That small bit of model code gives Django a lot of information. With it, Django
is able to:</p>
<ul class="simple">
<li>Create a database schema (<tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> statements) for this app.</li>
<li>Create a Python database-access API for accessing Poll and Choice objects.</li>
</ul>
<p>But first we need to tell our project that the <tt class="docutils literal"><span class="pre">polls</span></tt> app is installed.</p>
<div class="admonition-philosophy admonition ">
<p class="first admonition-title">Philosophy</p>
<p class="last">Django apps are &quot;pluggable&quot;: You can use an app in multiple projects, and
you can distribute apps, because they don't have to be tied to a given
Django installation.</p>
</div>
<p>Edit the <tt class="file docutils literal"><span class="pre">settings.py</span></tt> file again, and change the
<a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> setting to include the string <tt class="docutils literal"><span class="pre">'polls'</span></tt>. So
it'll look like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">INSTALLED_APPS</span> <span class="o">=</span> <span class="p">(</span>
<span class="s">&#39;django.contrib.auth&#39;</span><span class="p">,</span>
<span class="s">&#39;django.contrib.contenttypes&#39;</span><span class="p">,</span>
<span class="s">&#39;django.contrib.sessions&#39;</span><span class="p">,</span>
<span class="s">&#39;django.contrib.sites&#39;</span><span class="p">,</span>
<span class="s">&#39;django.contrib.messages&#39;</span><span class="p">,</span>
<span class="s">&#39;django.contrib.staticfiles&#39;</span><span class="p">,</span>
<span class="c"># Uncomment the next line to enable the admin:</span>
<span class="c"># &#39;django.contrib.admin&#39;,</span>
<span class="c"># Uncomment the next line to enable admin documentation:</span>
<span class="c"># &#39;django.contrib.admindocs&#39;,</span>
<span class="s">&#39;polls&#39;</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>
</div>
<p>Now Django knows to include the <tt class="docutils literal"><span class="pre">polls</span></tt> app. Let's run another
command:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py sql polls
</pre></div>
</div>
<p>You should see something similar to the following (the <tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">TABLE</span></tt> SQL
statements for the polls app):</p>
<div class="highlight-sql"><div class="highlight"><pre><span class="k">BEGIN</span><span class="p">;</span>
<span class="k">CREATE</span> <span class="k">TABLE</span> <span class="ss">&quot;polls_poll&quot;</span> <span class="p">(</span>
<span class="ss">&quot;id&quot;</span> <span class="nb">serial</span> <span class="k">NOT</span> <span class="k">NULL</span> <span class="k">PRIMARY</span> <span class="k">KEY</span><span class="p">,</span>
<span class="ss">&quot;question&quot;</span> <span class="nb">varchar</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span>
<span class="ss">&quot;pub_date&quot;</span> <span class="k">timestamp</span> <span class="k">with</span> <span class="n">time</span> <span class="k">zone</span> <span class="k">NOT</span> <span class="k">NULL</span>
<span class="p">);</span>
<span class="k">CREATE</span> <span class="k">TABLE</span> <span class="ss">&quot;polls_choice&quot;</span> <span class="p">(</span>
<span class="ss">&quot;id&quot;</span> <span class="nb">serial</span> <span class="k">NOT</span> <span class="k">NULL</span> <span class="k">PRIMARY</span> <span class="k">KEY</span><span class="p">,</span>
<span class="ss">&quot;poll_id&quot;</span> <span class="nb">integer</span> <span class="k">NOT</span> <span class="k">NULL</span> <span class="k">REFERENCES</span> <span class="ss">&quot;polls_poll&quot;</span> <span class="p">(</span><span class="ss">&quot;id&quot;</span><span class="p">)</span> <span class="k">DEFERRABLE</span> <span class="k">INITIALLY</span> <span class="k">DEFERRED</span><span class="p">,</span>
<span class="ss">&quot;choice&quot;</span> <span class="nb">varchar</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span>
<span class="ss">&quot;votes&quot;</span> <span class="nb">integer</span> <span class="k">NOT</span> <span class="k">NULL</span>
<span class="p">);</span>
<span class="k">COMMIT</span><span class="p">;</span>
</pre></div>
</div>
<p>Note the following:</p>
<ul class="simple">
<li>The exact output will vary depending on the database you are using.</li>
<li>Table names are automatically generated by combining the name of the app
(<tt class="docutils literal"><span class="pre">polls</span></tt>) and the lowercase name of the model -- <tt class="docutils literal"><span class="pre">poll</span></tt> and
<tt class="docutils literal"><span class="pre">choice</span></tt>. (You can override this behavior.)</li>
<li>Primary keys (IDs) are added automatically. (You can override this, too.)</li>
<li>By convention, Django appends <tt class="docutils literal"><span class="pre">&quot;_id&quot;</span></tt> to the foreign key field name.
(Yes, you can override this, as well.)</li>
<li>The foreign key relationship is made explicit by a <tt class="docutils literal"><span class="pre">REFERENCES</span></tt>
statement.</li>
<li>It's tailored to the database you're using, so database-specific field
types such as <tt class="docutils literal"><span class="pre">auto_increment</span></tt> (MySQL), <tt class="docutils literal"><span class="pre">serial</span></tt> (PostgreSQL), or
<tt class="docutils literal"><span class="pre">integer</span> <span class="pre">primary</span> <span class="pre">key</span></tt> (SQLite) are handled for you automatically. Same
goes for quoting of field names -- e.g., using double quotes or single
quotes. The author of this tutorial runs PostgreSQL, so the example
output is in PostgreSQL syntax.</li>
<li>The <a class="reference internal" href="../../ref/django-admin/#django-admin-sql"><tt class="xref std std-djadmin docutils literal"><span class="pre">sql</span></tt></a> command doesn't actually run the SQL in your database -
it just prints it to the screen so that you can see what SQL Django thinks
is required. If you wanted to, you could copy and paste this SQL into your
database prompt. However, as we will see shortly, Django provides an
easier way of committing the SQL to the database.</li>
</ul>
<p>If you're interested, also run the following commands:</p>
<ul class="simple">
<li><a class="reference internal" href="../../ref/django-admin/#django-admin-validate"><tt class="xref std std-djadmin docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">validate</span></tt></a> -- Checks for any errors
in the construction of your models.</li>
<li><a class="reference internal" href="../../ref/django-admin/#django-admin-sqlcustom"><tt class="xref std std-djadmin docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">sqlcustom</span> <span class="pre">polls</span></tt></a> -- Outputs any
<a class="reference internal" href="../../howto/initial-data/#initial-sql"><em>custom SQL statements</em></a> (such as table modifications or
constraints) that are defined for the application.</li>
<li><a class="reference internal" href="../../ref/django-admin/#django-admin-sqlclear"><tt class="xref std std-djadmin docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">sqlclear</span> <span class="pre">polls</span></tt></a> -- Outputs the
necessary <tt class="docutils literal"><span class="pre">DROP</span> <span class="pre">TABLE</span></tt> statements for this app, according to which
tables already exist in your database (if any).</li>
<li><a class="reference internal" href="../../ref/django-admin/#django-admin-sqlindexes"><tt class="xref std std-djadmin docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">sqlindexes</span> <span class="pre">polls</span></tt></a> -- Outputs the
<tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">INDEX</span></tt> statements for this app.</li>
<li><a class="reference internal" href="../../ref/django-admin/#django-admin-sqlall"><tt class="xref std std-djadmin docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">sqlall</span> <span class="pre">polls</span></tt></a> -- A combination of all
the SQL from the <a class="reference internal" href="../../ref/django-admin/#django-admin-sql"><tt class="xref std std-djadmin docutils literal"><span class="pre">sql</span></tt></a>, <a class="reference internal" href="../../ref/django-admin/#django-admin-sqlcustom"><tt class="xref std std-djadmin docutils literal"><span class="pre">sqlcustom</span></tt></a>, and
<a class="reference internal" href="../../ref/django-admin/#django-admin-sqlindexes"><tt class="xref std std-djadmin docutils literal"><span class="pre">sqlindexes</span></tt></a> commands.</li>
</ul>
<p>Looking at the output of those commands can help you understand what's actually
happening under the hood.</p>
<p>Now, run <a class="reference internal" href="../../ref/django-admin/#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a> again to create those model tables in your database:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py syncdb
</pre></div>
</div>
<p>The <a class="reference internal" href="../../ref/django-admin/#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a> command runs the SQL from <a class="reference internal" href="../../ref/django-admin/#django-admin-sqlall"><tt class="xref std std-djadmin docutils literal"><span class="pre">sqlall</span></tt></a> on your
database for all apps in <a class="reference internal" href="../../ref/settings/#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> that don't already exist in
your database. This creates all the tables, initial data and indexes for any
apps you've added to your project since the last time you ran syncdb.
<a class="reference internal" href="../../ref/django-admin/#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a> can be called as often as you like, and it will only ever
create the tables that don't exist.</p>
<p>Read the <a class="reference internal" href="../../ref/django-admin/"><em>django-admin.py documentation</em></a> for full
information on what the <tt class="docutils literal"><span class="pre">manage.py</span></tt> utility can do.</p>
</div>
<div class="section" id="s-playing-with-the-api">
<span id="playing-with-the-api"></span><h2>Playing with the API<a class="headerlink" href="#playing-with-the-api" title="Permalink to this headline"></a></h2>
<p>Now, let's hop into the interactive Python shell and play around with the free
API Django gives you. To invoke the Python shell, use this command:</p>
<div class="highlight-bash"><div class="highlight"><pre>python manage.py shell
</pre></div>
</div>
<p>We're using this instead of simply typing &quot;python&quot;, because <tt class="file docutils literal"><span class="pre">manage.py</span></tt>
sets the <tt class="docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></tt> environment variable, which gives Django
the Python import path to your <tt class="file docutils literal"><span class="pre">settings.py</span></tt> file.</p>
<div class="admonition-bypassing-manage-py admonition ">
<p class="first admonition-title">Bypassing manage.py</p>
<p>If you'd rather not use <tt class="file docutils literal"><span class="pre">manage.py</span></tt>, no problem. Just set the
<tt class="docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></tt> environment variable to <tt class="docutils literal"><span class="pre">mysite.settings</span></tt> and
run <tt class="docutils literal"><span class="pre">python</span></tt> from the same directory <tt class="file docutils literal"><span class="pre">manage.py</span></tt> is in (or ensure
that directory is on the Python path, so that <tt class="docutils literal"><span class="pre">import</span> <span class="pre">mysite</span></tt> works).</p>
<p class="last">For more information on all of this, see the <a class="reference internal" href="../../ref/django-admin/"><em>django-admin.py
documentation</em></a>.</p>
</div>
<p>Once you're in the shell, explore the <a class="reference internal" href="../../topics/db/queries/"><em>database API</em></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">polls.models</span> <span class="kn">import</span> <span class="n">Poll</span><span class="p">,</span> <span class="n">Choice</span> <span class="c"># Import the model classes we just wrote.</span>
<span class="go"># No polls are in the system yet.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[]</span>
<span class="go"># Create a new Poll.</span>
<span class="go"># Support for time zones is enabled in the default settings file, so</span>
<span class="go"># Django expects a datetime with tzinfo for pub_date. Use timezone.now()</span>
<span class="go"># instead of datetime.datetime.now() and it will do the right thing.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.utils</span> <span class="kn">import</span> <span class="n">timezone</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poll</span><span class="p">(</span><span class="n">question</span><span class="o">=</span><span class="s">&quot;What&#39;s new?&quot;</span><span class="p">,</span> <span class="n">pub_date</span><span class="o">=</span><span class="n">timezone</span><span class="o">.</span><span class="n">now</span><span class="p">())</span>
<span class="go"># Save the object into the database. You have to call save() explicitly.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
<span class="go"># Now it has an ID. Note that this might say &quot;1L&quot; instead of &quot;1&quot;, depending</span>
<span class="go"># on which database you&#39;re using. That&#39;s no biggie; it just means your</span>
<span class="go"># database backend prefers to return integers as Python long integer</span>
<span class="go"># objects.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">id</span>
<span class="go">1</span>
<span class="go"># Access database columns via Python attributes.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">question</span>
<span class="go">&quot;What&#39;s new?&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">pub_date</span>
<span class="go">datetime.datetime(2012, 2, 26, 13, 0, 0, 775217, tzinfo=&lt;UTC&gt;)</span>
<span class="go"># Change values by changing the attributes, then calling save().</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">question</span> <span class="o">=</span> <span class="s">&quot;What&#39;s up?&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
<span class="go"># objects.all() displays all the polls in the database.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[&lt;Poll: Poll object&gt;]</span>
</pre></div>
</div>
<p>Wait a minute. <tt class="docutils literal"><span class="pre">&lt;Poll:</span> <span class="pre">Poll</span> <span class="pre">object&gt;</span></tt> is, utterly, an unhelpful representation
of this object. Let's fix that by editing the polls model (in the
<tt class="docutils literal"><span class="pre">polls/models.py</span></tt> file) and adding a
<a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> method to both <tt class="docutils literal"><span class="pre">Poll</span></tt> and
<tt class="docutils literal"><span class="pre">Choice</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Poll</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="c"># ...</span>
<span class="k">def</span> <span class="nf">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">question</span>
<span class="k">class</span> <span class="nc">Choice</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="c"># ...</span>
<span class="k">def</span> <span class="nf">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">choice</span>
</pre></div>
</div>
<p>It's important to add <a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> methods to
your models, not only for your own sanity when dealing with the interactive
prompt, but also because objects' representations are used throughout Django's
automatically-generated admin.</p>
<div class="admonition-why-meth-django-db-models-model-unicode-and-not-meth-django-db-models-model-str admonition ">
<p class="first admonition-title">Why <a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> and not
<a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__str__" title="django.db.models.Model.__str__"><tt class="xref py py-meth docutils literal"><span class="pre">__str__()</span></tt></a>?</p>
<p>If you're familiar with Python, you might be in the habit of adding
<a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__str__" title="django.db.models.Model.__str__"><tt class="xref py py-meth docutils literal"><span class="pre">__str__()</span></tt></a> methods to your classes, not
<a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> methods. We use
<a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> here because Django models deal
with Unicode by default. All data stored in your database is converted to
Unicode when it's returned.</p>
<p>Django models have a default <a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__str__" title="django.db.models.Model.__str__"><tt class="xref py py-meth docutils literal"><span class="pre">__str__()</span></tt></a> method
that calls <a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> and converts the
result to a UTF-8 bytestring. This means that <tt class="docutils literal"><span class="pre">unicode(p)</span></tt> will return a
Unicode string, and <tt class="docutils literal"><span class="pre">str(p)</span></tt> will return a normal string, with characters
encoded as UTF-8.</p>
<p class="last">If all of this is gibberish to you, just remember to add
<a class="reference internal" href="../../ref/models/instances/#django.db.models.Model.__unicode__" title="django.db.models.Model.__unicode__"><tt class="xref py py-meth docutils literal"><span class="pre">__unicode__()</span></tt></a> methods to your models. With any
luck, things should Just Work for you.</p>
</div>
<p>Note these are normal Python methods. Let's add a custom method, just for
demonstration:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">from</span> <span class="nn">django.utils</span> <span class="kn">import</span> <span class="n">timezone</span>
<span class="c"># ...</span>
<span class="k">class</span> <span class="nc">Poll</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="c"># ...</span>
<span class="k">def</span> <span class="nf">was_published_recently</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">pub_date</span> <span class="o">&gt;=</span> <span class="n">timezone</span><span class="o">.</span><span class="n">now</span><span class="p">()</span> <span class="o">-</span> <span class="n">datetime</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">days</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Note the addition of <tt class="docutils literal"><span class="pre">import</span> <span class="pre">datetime</span></tt> and <tt class="docutils literal"><span class="pre">from</span> <span class="pre">django.utils</span> <span class="pre">import</span>
<span class="pre">timezone</span></tt>, to reference Python's standard <a class="reference external" href="http://docs.python.org/2.7/library/datetime.html#datetime" title="(in Python v2.7)"><tt class="xref py py-mod docutils literal"><span class="pre">datetime</span></tt></a> module and Django's
time-zone-related utilities in <a class="reference internal" href="../../ref/utils/#module-django.utils.timezone" title="django.utils.timezone: Timezone support."><tt class="xref py py-mod docutils literal"><span class="pre">django.utils.timezone</span></tt></a>, respectively. If
you aren't familiar with time zone handling in Python, you can learn more in
the <a class="reference internal" href="../../topics/i18n/timezones/"><em>time zone support docs</em></a>.</p>
<p>Save these changes and start a new Python interactive shell by running
<tt class="docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">shell</span></tt> again:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">polls.models</span> <span class="kn">import</span> <span class="n">Poll</span><span class="p">,</span> <span class="n">Choice</span>
<span class="go"># Make sure our __unicode__() addition worked.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[&lt;Poll: What&#39;s up?&gt;]</span>
<span class="go"># Django provides a rich database lookup API that&#39;s entirely driven by</span>
<span class="go"># keyword arguments.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="go">[&lt;Poll: What&#39;s up?&gt;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">question__startswith</span><span class="o">=</span><span class="s">&#39;What&#39;</span><span class="p">)</span>
<span class="go">[&lt;Poll: What&#39;s up?&gt;]</span>
<span class="go"># Get the poll whose year is 2012.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">pub_date__year</span><span class="o">=</span><span class="mi">2012</span><span class="p">)</span>
<span class="go">&lt;Poll: What&#39;s up?&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="o">...</span>
<span class="nc">DoesNotExist: Poll matching query does not exist. Lookup parameters were {&#39;id&#39;</span>: <span class="n-Identifier">2}</span>
<span class="go"># Lookup by a primary key is the most common case, so Django provides a</span>
<span class="go"># shortcut for primary-key exact lookups.</span>
<span class="go"># The following is identical to Poll.objects.get(id=1).</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">pk</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="go">&lt;Poll: What&#39;s up?&gt;</span>
<span class="go"># Make sure our custom method worked.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">pk</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">was_published_recently</span><span class="p">()</span>
<span class="go">True</span>
<span class="go"># Give the Poll a couple of Choices. The create call constructs a new</span>
<span class="go"># choice object, does the INSERT statement, adds the choice to the set</span>
<span class="go"># of available choices and returns the new Choice object. Django creates</span>
<span class="go"># a set to hold the &quot;other side&quot; of a ForeignKey relation</span>
<span class="go"># (e.g. a poll&#39;s choices) which can be accessed via the API.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poll</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">pk</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="go"># Display any choices from the related object set -- none so far.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[]</span>
<span class="go"># Create three choices.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">choice</span><span class="o">=</span><span class="s">&#39;Not much&#39;</span><span class="p">,</span> <span class="n">votes</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="go">&lt;Choice: Not much&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">choice</span><span class="o">=</span><span class="s">&#39;The sky&#39;</span><span class="p">,</span> <span class="n">votes</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="go">&lt;Choice: The sky&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">choice</span><span class="o">=</span><span class="s">&#39;Just hacking again&#39;</span><span class="p">,</span> <span class="n">votes</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="go"># Choice objects have API access to their related Poll objects.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span><span class="o">.</span><span class="n">poll</span>
<span class="go">&lt;Poll: What&#39;s up?&gt;</span>
<span class="go"># And vice versa: Poll objects get access to Choice objects.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="go">[&lt;Choice: Not much&gt;, &lt;Choice: The sky&gt;, &lt;Choice: Just hacking again&gt;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">count</span><span class="p">()</span>
<span class="go">3</span>
<span class="go"># The API automatically follows relationships as far as you need.</span>
<span class="go"># Use double underscores to separate relationships.</span>
<span class="go"># This works as many levels deep as you want; there&#39;s no limit.</span>
<span class="go"># Find all Choices for any poll whose pub_date is in 2012.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Choice</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">poll__pub_date__year</span><span class="o">=</span><span class="mi">2012</span><span class="p">)</span>
<span class="go">[&lt;Choice: Not much&gt;, &lt;Choice: The sky&gt;, &lt;Choice: Just hacking again&gt;]</span>
<span class="go"># Let&#39;s delete one of the choices. Use delete() for that.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">choice_set</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">choice__startswith</span><span class="o">=</span><span class="s">&#39;Just hacking&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
</pre></div>
</div>
<p>For more information on model relations, see <a class="reference internal" href="../../ref/models/relations/"><em>Accessing related objects</em></a>. For more on how to use double underscores to perform
field lookups via the API, see <a class="reference internal" href="../../topics/db/queries/#field-lookups-intro"><em>Field lookups</em></a>. For
full details on the database API, see our <a class="reference internal" href="../../topics/db/queries/"><em>Database API reference</em></a>.</p>
<p>When you're comfortable with the API, read <a class="reference internal" href="../tutorial02/"><em>part 2 of this tutorial</em></a> to get Django's automatic admin working.</p>
</div>
</div>
<div id="content-secondary">
<h2 id="comments">Questions/Feedback</h2>
<p>Having trouble? We'd like to help!</p>
<ul>
<li>
Try the <a href="/en/1.4/faq/">FAQ</a>
— it's got answers to many common questions.
</li>
<li>
Search for information in the <a
href="http://groups.google.com/group/django-users/">archives of the
django-users mailing list</a>, or <a
href="http://groups.google.com/group/django-users/">post a question</a>.
</li>
<li>
Ask a question in the <a href="irc://irc.freenode.net/">#django IRC
channel</a>, or search the <a href="http://django-irc-logs.com/">IRC
logs</a> to see if it has been asked before.
</li>
<li>
If you notice errors with this documentation, please <a
href="https://code.djangoproject.com/newticket?component=Documentation">
open a ticket</a> and let us know! Please only use the ticket tracker for
criticisms and improvements on the docs. For tech support, use the
resources above.
</li>
</ul>
</div>
</div>
<!-- END #content-main -->
<div id="content-related" class="sidebar">
<h2>Search</h2>
<form action="/search/" id="sidebar_search" class="search">
<div>
<p>
<input type="search" name="q" id="id_sidebar_search_q" />
</p>
<p>
<label for="id_sidebar_search_release">Version:</label>
<select name="release" id="id_sidebar_search_release">
<option value="2">Django 1.0</option>
<option value="3">Django 1.1</option>
<option value="4">Django 1.2</option>
<option value="5">Django 1.3</option>
<option value="6" selected="selected">Django 1.4</option>
<option value="1">Development trunk</option>
</select>
</p>
<p>
<input type="submit" class="submit" value="Search" />
</p>
</div>
</form>
<h2>Contents</h2>
<ul>
<li><a class="reference internal" href="#">Writing your first Django app, part 1</a><ul>
<li><a class="reference internal" href="#creating-a-project">Creating a project</a><ul>
<li><a class="reference internal" href="#the-development-server">The development server</a></li>
<li><a class="reference internal" href="#database-setup">Database setup</a></li>
</ul>
</li>
<li><a class="reference internal" href="#creating-models">Creating models</a></li>
<li><a class="reference internal" href="#activating-models">Activating models</a></li>
<li><a class="reference internal" href="#playing-with-the-api">Playing with the API</a></li>
</ul>
</li>
</ul>
<h2>Browse</h2>
<ul>
<li>Prev: <a href="../install/">Quick install guide</a></li>
<li>Next: <a href="../tutorial02/">Writing your first Django app, part 2</a></li>
<li><a href="/en/1.4/contents/">Table of contents</a></li>
<li><a href="/en/1.4/genindex/">General Index</a></li>
<li><a href="/en/1.4/py-modindex/">Python Module Index</a></li>
</ul>
<h2>You are here:</h2>
<ul>
<li>
<a href="/en/1.4/">Django 1.4 documentation</a>
<ul><li><a href="../">Getting started</a>
<ul><li>Writing your first Django app, part 1</li></ul>
</li></ul>
</li>
</ul>
<h2>Download:</h2>
<p>
Offline (Django 1.4):
<a href="https://www.djangoproject.com/m/docs/django-docs-1.4-en.zip">HTML</a> |
<a href="http://media.readthedocs.org/pdf/django/1.4.X/django.pdf">PDF</a> |
<a href="http://media.readthedocs.org/epub/django/1.4.X/django.epub">ePub</a>
<br>
<span class="quiet">Provided by <a href="http://readthedocs.org/">Read the Docs</a>.
</p>
</div>
<!-- END #content-related -->
</div>
<!-- END #content -->
<div id="footer">
<p>&copy; 2005-2012 <a href="https://www.djangoproject.com/foundation/">Django Software Foundation</a> unless otherwise noted. Django is a registered trademark of the Django Software Foundation.
<a href="http://mediatemple.net/">Linux Web hosting</a> graciously provided by Media Temple.
</p>
</div>
<!-- END #footer -->
</div>
<!-- END #container -->
</body>
</html>

@ -0,0 +1,650 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bookie Weekly Update: April 22nd 2012 &laquo; Tech Rantings from a Michigan Techie</title>
<meta name="description" content="Just another WordPress.com weblog" />
<link rel="stylesheet" href="http://s1.wp.com/wp-content/themes/pub/unsleepable/style.css?m=1306954510g" type="text/css" media="screen" />
<!--[if IE]>
<link rel="stylesheet" href="http://s1.wp.com/wp-content/themes/pub/unsleepable/ie.css?m=1314316350g" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" href="http://s1.wp.com/wp-content/themes/pub/unsleepable/ie6.css?m=1221676594g" type="text/css" media="screen" />
<![endif]-->
<link rel="pingback" href="http://blog.mitechie.com/xmlrpc.php" />
<script src='http://r-login.wordpress.com/remote-login.php?action=js&amp;host=blog.mitechie.com&amp;id=11465279&amp;t=1336015328&amp;back=blog.mitechie.com%2F2012%2F04%2F22%2Fbookie-weekly-update-april-22nd-2012%2F' type="text/javascript"></script>
<script type="text/javascript">
/* <![CDATA[ */
if ( 'function' === typeof WPRemoteLogin ) {
document.cookie = "wordpress_test_cookie=test; path=/";
if ( document.cookie.match( /(;|^)\s*wordpress_test_cookie\=/ ) ) {
WPRemoteLogin();
}
}
/* ]]> */
</script>
<link rel="alternate" type="application/rss+xml" title="Tech Rantings from a Michigan Techie &raquo; Feed" href="http://blog.mitechie.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="Tech Rantings from a Michigan Techie &raquo; Comments Feed" href="http://blog.mitechie.com/comments/feed/" />
<link rel="alternate" type="application/rss+xml" title="Tech Rantings from a Michigan Techie &raquo; Bookie Weekly Update: April 22nd&nbsp;2012 Comments Feed" href="http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/feed/" />
<script type="text/javascript">
/* <![CDATA[ */
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
/* ]]> */
</script>
<link rel="stylesheet" href="http://s0.wp.com/wp-content/themes/h4/global.css?m=1313010094g" type="text/css" />
<link rel='stylesheet' id='loggedout-subscribe-css' href='http://s1.wp.com/wp-content/blog-plugins/loggedout-follow/widget.css?m=1330044119g&#038;ver=20120104' type='text/css' media='all' />
<link rel='stylesheet' id='post-reactions-css' href='http://s1.wp.com/wp-content/mu-plugins/post-flair/style.css?m=1335512048g&#038;ver=4' type='text/css' media='all' />
<link rel='stylesheet' id='a8c-global-print-css' href='http://s2.wp.com/wp-content/mu-plugins/global-print/global-print.css?m=1335386953g&#038;ver=20120418' type='text/css' media='print' />
<script type='text/javascript' src='http://s0.wp.com/wp-includes/js/jquery/jquery.js?m=1333391137g&#038;ver=1.7.2'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var LoggedOutFollow = {"invalid_email":"Your subscription did not succeed, please try again with a valid email address."};
/* ]]> */
</script>
<script type='text/javascript' src='http://s1.wp.com/wp-content/blog-plugins/loggedout-follow/widget.js?m=1329327657g&#038;ver=20120215'></script>
<script type='text/javascript' src='http://s1.wp.com/wp-includes/js/comment-reply.js?m=1231878779g&#038;ver=3.4-beta3-20681'></script>
<link rel='stylesheet' id='highlander-comments-css' href='http://s0.wp.com/wp-content/mu-plugins/highlander-comments/style.css?m=1334188075g&#038;ver=20110620' type='text/css' media='all' />
<!--[if lt IE 8]>
<link rel='stylesheet' id='highlander-comments-ie7-css' href='http://s0.wp.com/wp-content/mu-plugins/highlander-comments/style-ie7.css?m=1307172283g&#038;ver=20110606' type='text/css' media='all' />
<![endif]-->
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://mitechie.wordpress.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://mitechie.wordpress.com/wp-includes/wlwmanifest.xml" />
<link rel='prev' title='Bookie Weekly Status Report Returns! &#8211; April 15&nbsp;2012' href='http://blog.mitechie.com/2012/04/15/bookie-weekly-status-report-returns-april-15-2012/' />
<link rel='next' title='Weekly Status Report: April&nbsp;29th' href='http://blog.mitechie.com/2012/04/29/weekly-status-report-april-29th/' />
<meta name="generator" content="WordPress.com" />
<link rel='canonical' href='http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/' />
<link rel='shortlink' href='http://wp.me/pM6DR-60' />
<link rel="alternate" type="application/json+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=json&amp;url=http%3A%2F%2Fblog.mitechie.com%2F2012%2F04%2F22%2Fbookie-weekly-update-april-22nd-2012%2F&amp;for=wpcom-auto-discovery" /><link rel="alternate" type="application/xml+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=xml&amp;url=http%3A%2F%2Fblog.mitechie.com%2F2012%2F04%2F22%2Fbookie-weekly-update-april-22nd-2012%2F&amp;for=wpcom-auto-discovery" /><meta property="og:type" content="article" />
<meta property="og:title" content="Bookie Weekly Update: April 22nd&nbsp;2012" />
<meta property="og:url" content="http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/" />
<meta property="og:description" content="Another week, another few lines of code, and yay for two weeks in a row! Bookie Not a ton here, just some CSS updates and updating the backup script for pulling the INI correctly. Bookie Parser I s..." />
<meta property="og:site_name" content="Tech Rantings from a Michigan Techie" />
<link rel="shortcut icon" type="image/x-icon" href="http://s2.wp.com/i/favicon.ico?m=1311976025g" sizes="16x16 24x24 32x32 48x48" />
<link rel="icon" type="image/x-icon" href="http://s2.wp.com/i/favicon.ico?m=1311976025g" sizes="16x16 24x24 32x32 48x48" />
<link rel="apple-touch-icon-precomposed" href="http://s0.wp.com/i/webclip.png?m=1311618091g" />
<link rel='openid.server' href='http://mitechie.wordpress.com/?openidserver=1' />
<link rel='openid.delegate' href='http://mitechie.wordpress.com/' />
<link rel="search" type="application/opensearchdescription+xml" href="http://blog.mitechie.com/osd.xml" title="Tech Rantings from a Michigan Techie" />
<link rel="search" type="application/opensearchdescription+xml" href="http://wordpress.com/opensearch.xml" title="WordPress.com" />
<script type="text/javascript" src="http://use.typekit.net/bha4agr.js"></script><script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<style type="text/css">/* Site Title */ .wf-loading #title { visibility: hidden; } .wf-active #title { font-size: 14px; } .wf-loading #title a { visibility: hidden; } .wf-active #title a { font-family: proxima-nova-1,proxima-nova-2,"Lucida Grande",Verdana,Arial,Sans-Serif; font-style: normal; font-weight: 700; font-variant: normal; font-size: 24px; }
/* Headings */ .wf-loading h1,.wf-loading h2,.wf-loading h3,.wf-loading h4 { visibility: hidden; } .wf-active h1,.wf-active h2,.wf-active h3,.wf-active h4 { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,"Lucida Grande",Verdana,Arial,Sans-Serif; font-style: normal; font-weight: 700; font-variant: normal; } .wf-loading .pagetitle h2 { visibility: hidden; } .wf-active .pagetitle h2 { font-weight: 700; font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Helvetica,Arial,Sans-Serif; font-style: normal; font-variant: normal; } .wf-loading .secondary h2 { visibility: hidden; } .wf-active .secondary h2 { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Helvetica,Arial,Sans-Serif; font-style: normal; font-weight: 700; font-variant: normal; } .wf-loading .secondary h2 a:hover { visibility: hidden; } .wf-active .secondary h2 a:hover { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Helvetica,Arial,Sans-Serif; font-style: normal; font-weight: 700; font-variant: normal; } .wf-loading .permalink .primary .aside h3,.wf-loading .primary h3,.wf-loading .primary h4 { visibility: hidden; } .wf-active .permalink .primary .aside h3,.wf-active .primary h3,.wf-active .primary h4 { font-weight: 700; } .wf-loading .primary .aside h3 { visibility: hidden; } .wf-active .primary .aside h3 { font-weight: 700; } .wf-loading .comments h4 a { visibility: hidden; } .wf-active .comments h4 a { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,!important; font-style: normal; font-weight: 700; font-variant: normal; } .wf-loading .comments h4 { visibility: hidden; } .wf-active .comments h4 { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,!important; font-style: normal; font-weight: 700; font-variant: normal; } .wf-loading #glass-bottomblock h2 { visibility: hidden; } .wf-active #glass-bottomblock h2 { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Helvetica,Arial,!important; font-style: normal; font-weight: 700; font-variant: normal; }
/* Body Text */ .wf-loading body { visibility: hidden; } .wf-active body { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,"Lucida Grande",Verdana,Arial,Sans-Serif; font-variant: normal; font-size: 12px; } .wf-loading ul.secondary { visibility: hidden; } .wf-active ul.secondary { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,MS; font-variant: normal; font-size: 13px; } .wf-loading .comments .primary .metalink,.wf-loading .primary .item .itemhead .metalink { visibility: hidden; } .wf-active .comments .primary .metalink,.wf-active .primary .item .itemhead .metalink { font-size: 2.02em; } .wf-loading .primary .aside .itemhead .metalink { visibility: hidden; } .wf-active .primary .aside .itemhead .metalink { font-size: 1.57em; } .wf-loading .permalink .primary .aside .itemtext { visibility: hidden; } .wf-active .permalink .primary .aside .itemtext { font-size: 1.57em; } .wf-loading .metadata { visibility: hidden; } .wf-active .metadata { font-size: 1em; } .wf-loading .chronodata { visibility: hidden; } .wf-active .chronodata { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Helvetica,Arial,Sans-Serif; font-variant: normal; font-size: 26px; } .wf-loading .primary .item .itemtext { visibility: hidden; } .wf-active .primary .item .itemtext { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,MS; font-variant: normal; font-size: 1.34em; } .wf-loading .commentmetadata { visibility: hidden; } .wf-active .commentmetadata { font-size: 13px; } .wf-loading .comments .commentlist li .commentauthor { visibility: hidden; } .wf-active .comments .commentlist li .commentauthor { font-size: 1.57em; } .wf-loading .comments .commentlist li .counter { visibility: hidden; } .wf-active .comments .commentlist li .counter { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Helvetica,Sans-Serif; font-variant: normal; font-size: 1.68em; } .wf-loading .comments .pinglist { visibility: hidden; } .wf-active .comments .pinglist { font-size: 1.34em; } .wf-loading .comments .pinglist li small { visibility: hidden; } .wf-active .comments .pinglist li small { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,Arial,Sans-Serif; font-variant: normal; font-size: 0.9em; } .wf-loading .comments #leavecomment { visibility: hidden; } .wf-active .comments #leavecomment { font-size: 2em; } .wf-loading .comments #loading { visibility: hidden; } .wf-active .comments #loading { font-size: 2em; } .wf-loading .item2 { visibility: hidden; } .wf-active .item2 { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,MS; font-variant: normal; font-size: 1.34em; } .wf-loading .itemtext2 { visibility: hidden; } .wf-active .itemtext2 { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,MS; font-variant: normal; font-size: 1.34em; } .wf-loading .delicious-extended { visibility: hidden; } .wf-active .delicious-extended { font-size: 13px; } .wf-loading #glass-bottomblock { visibility: hidden; } .wf-active #glass-bottomblock { font-family: ff-meta-serif-web-pro-1,ff-meta-serif-web-pro-2,MS; font-variant: normal; font-size: 1.288em; } .wf-loading .wp-caption p.wp-caption-text { visibility: hidden; } .wf-active .wp-caption p.wp-caption-text { font-size: 12px; }
</style>
<meta name="application-name" content="Tech Rantings from a Michigan Techie" /><meta name="msapplication-window" content="width=device-width;height=device-height" /><meta name="msapplication-tooltip" content="Just another WordPress.com weblog" /><meta name="msapplication-task" content="name=Subscribe;action-uri=http://blog.mitechie.com/feed/;icon-uri=http://s2.wp.com/i/favicon.ico" /><meta name="msapplication-task" content="name=Sign up for a free blog;action-uri=http://wordpress.com/signup/;icon-uri=http://s2.wp.com/i/favicon.ico" /><meta name="msapplication-task" content="name=WordPress.com Support;action-uri=http://support.wordpress.com/;icon-uri=http://s2.wp.com/i/favicon.ico" /><meta name="msapplication-task" content="name=WordPress.com Forums;action-uri=http://forums.wordpress.com/;icon-uri=http://s2.wp.com/i/favicon.ico" />
<link rel="stylesheet" type="text/css" href="http://s2.wp.com/?custom-css=1&#038;csblog=M6DR&#038;cscache=6&#038;csrev=6" />
</head>
<body class="single single-post postid-372 single-format-standard typekit-enabled highlander-enabled highlander-light">
<div id="page">
<div id="header">
<div class="top">
<div id="title">
<a href="http://blog.mitechie.com/" title="Back to the front page">Tech Rantings from a Michigan Techie</a>
</div>
<ul id="menu">
<li class="page_item page-item-2"><a href="http://blog.mitechie.com/about/">About</a></li>
<li class="page_item page-item-140"><a href="http://blog.mitechie.com/code/">Code</a></li>
<li class="page_item page-item-145"><a href="http://blog.mitechie.com/tools/">Tools</a></li>
<li class="page_item page-item-155"><a href="http://blog.mitechie.com/talks/">Talks</a></li>
</ul>
</div>
</div>
<hr />
<div class="content">
<div class="primary">
<div class="navigation">
<div class="left"><span>&laquo;</span> <a href="http://blog.mitechie.com/2012/04/15/bookie-weekly-status-report-returns-april-15-2012/">Bookie Weekly Status Report Returns! &#8211; April 15&nbsp;2012</a></div>
<div class="right"> <a href="http://blog.mitechie.com/2012/04/29/weekly-status-report-april-29th/">Weekly Status Report: April&nbsp;29th</a> <span>&raquo;</span></div>
<div class="clear"></div>
</div>
<div id="post-372" class="post-372 post type-post status-publish format-standard hentry category-bookie tag-api tag-bookie-2 tag-github tag-parser tag-penguicon tag-readability_lxml item entry">
<div class="itemhead">
<h3>
Bookie Weekly Update: April 22nd&nbsp;2012 </h3>
<div class="chronodata">22Apr12</div>
<!-- The following two sections are for a noteworthy plugin currently in alpha. They'll get cleaned up and integrated better -->
</div>
<div class="itemtext">
<p>Another week, another few lines of code, and yay for two weeks in a row!</p>
<div class="section" id="bookie">
<h1><a class="reference external" href="http://github.com/mitechie/Bookie">Bookie</a></h1>
<p>Not a ton here, just some CSS updates and updating the backup script for pulling the INI correctly.</p>
</div>
<div class="section" id="bookie-parser">
<h1><a class="reference external" href="http://github.com/mitechie/bookie_parser">Bookie Parser</a></h1>
<p>I spent some time cleaning up the CSS. I did some research on the most readable fonts for screens and surprisingly, it seems that sans serif wins on digital displays. So I updated the CSS and combined with some work on the Bookie main CSS files to make the readable pages a bit nicer. I&#8217;ve still got some more cleanup to do, but it reads a bit nicer now.</p>
<p>I also fixed the html generated to not have the empty body tag. It was due to the way the readable parsing library was giving me a full html document of content. See the updates over there for some bigger updates.</p>
<p>Finally, I added a form on the main page so you can try it out on a url just by entering it. So if you&#8217;re just curious what it does, <a class="reference external" href="http://readable.bmark.us">go try it out</a>!</p>
</div>
<div class="section" id="bookie-api">
<h1><a class="reference external" href="http://github.com/mitechie/bookie_api">Bookie Api</a></h1>
<p>Just added a <cite>ping</cite> command. It should help make sure that the configuration is correct for new users. It&#8217;s also a nice start to a non-admin specific api command. A little bit of cleanup aside from that, but nothing major.</p>
</div>
<div class="section" id="readability-lxml">
<h1><a class="reference external" href="https://github.com/mitechie/python-readability">readability_lxml</a></h1>
<p>Currently, Bookie uses a library called <a class="reference external" href="https://github.com/dcramer/decruft">decruft</a> for parsing html pages for the actual important article content. The <a class="reference external">bookie_parser</a> project is using a different fork of that called <a class="reference external" href="https://github.com/mitechie/python-readability">readability_lxml</a>. The author is a bit open to merging changes in and actually says she&#8217;s in &#8216;maintenance mode&#8217;. Since I kind of want a really decent library for this, it&#8217;s an important feature, I started hacking on it. In the process, this is where my week of hacking went.</p>
<p>First I updated it to allow me to get back only a partial html document vs an entire <cite>&lt;html&gt;</cite> doc. I then fixed some bugs, started cleaning up the code (adding tests, making the command line client all nice and argepare&#8217;y) etc. In the process I noticed that there&#8217;s a big branch in Github that adds a ton of things like multiple page document support and such. I&#8217;ve started to try to pull his branch into my work and the origin author&#8217;s code. It&#8217;s a LOT of <cite>git cherry-pick</cite> and really a pain since I want to clean up the code as I go. Unfortunately, this just means that Git gets confused on future merges since the code&#8217;s changed between commits. Ugh!</p>
<p>I&#8217;m about half way done though and I hope this will leave us with one solid library to do this parsing. I&#8217;m hoping to kind of take over stewardship of the library as I complete this work. It should hopefully make <a class="reference external" href="http://github.com/mitechie/Bookie">Bookie</a> and <a class="reference external" href="http://github.com/mitechie/bookie_parser">bookie_parser</a> all the more awesome.</p>
</div>
<div class="section" id="the-coming-week">
<h1>The coming week</h1>
<p>I&#8217;m giving a talk on the <a class="reference external" href="http://yuilibrary.com/">YUI JavaScript library</a> at <a class="reference external" href="http://www.penguicon.org">Penguicon</a>. This means my<br />
hacking time will be a bit less since I&#8217;ve got a presentation to prepare for. Next week&#8217;s status report might be a bit light and boring, but hey, maybe I&#8217;ll scrounge up some more beta users of Bookie while at the conference.</p>
<div class="sharedaddy sd-like-enabled"><div class="wpl-likebox sd-block sd-like"><h3 class="sd-title">Like this:</h3><div class="sd-content"><div id="like-372" class="wpl-button "><a href='http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/?like=1&amp;_wpnonce=b10571cb2a' title='I like this post' class='like needs-login sd-button' rel='nofollow'><span>Like</span></a></div><div class="wpl-count sd-like-count">Be the first to like this post.</div></div></div></div>
</div>
<br class="clear" />
<small class="metadata">
<span class="category">Filed under: <a href="http://blog.mitechie.com/category/bookie/" title="View all posts in Bookie" rel="category tag">Bookie</a> </span>
&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/#respond" class="commentslink" title="Comment on Bookie Weekly Update: April 22nd&nbsp;2012">Leave a <span>Comment</span></a> <br />Tags: <a href="http://blog.mitechie.com/tag/api/" rel="tag">api</a>, <a href="http://blog.mitechie.com/tag/bookie-2/" rel="tag">bookie</a>, <a href="http://blog.mitechie.com/tag/github/" rel="tag">github</a>, <a href="http://blog.mitechie.com/tag/parser/" rel="tag">parser</a>, <a href="http://blog.mitechie.com/tag/penguicon/" rel="tag">penguicon</a>, <a href="http://blog.mitechie.com/tag/readability_lxml/" rel="tag">readability_lxml</a><br /> </small>
</div>
<hr />
<div class="comments" id="comments">
<h4>
<a href="#comments">
No Responses Yet to &#8220;Bookie Weekly Update: April 22nd&nbsp;2012&#8221; </a>
</h4>
<div class="metalinks">
<span class="commentsrsslink"><a href='http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/feed/'>Feed for this Entry</a></span>
<span class="trackbacklink"><a href="http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/trackback/" title="Copy this URI to trackback this entry.">Trackback Address</a></span> </div>
<ol class="commentlist" id='commentlist'>
<!-- If comments are open, but there are no comments. -->
<li id="leavecomment">Leave a Comment</li>
</ol>
<div id="respond">
<h3 id="reply-title">Leave a Reply <small><a rel="nofollow" id="cancel-comment-reply-link" href="/2012/04/22/bookie-weekly-update-april-22nd-2012/#respond" style="display:none;">Cancel reply</a></small></h3>
<form action="http://blog.mitechie.com/wp-comments-post.php" method="post" id="commentform">
<input type="hidden" name="hc_post_as" id="hc_post_as" value="guest" />
<div class="comment-form-field comment-textarea">
<label for="comment">Enter your comment here...</label>
<div id="comment-form-comment"><textarea id="comment" name="comment"></textarea></div>
</div>
<div id="comment-form-identity">
<div id="comment-form-nascar">
<p>Fill in your details below or click an icon to log in:</p>
<ul>
<li class="selected" style="display:none;">
<a href="#comment-form-guest" id="postas-guest" title="Guest">
<span></span>
</a>
</li>
<li>
<a href="#comment-form-load-service:WordPress.com" id="postas-wordpress" title="WordPress.com">
<span></span>
</a>
</li>
<li>
<a href="#comment-form-load-service:Twitter" id="postas-twitter" title="Twitter">
<span></span>
</a>
</li>
<li>
<a href="#comment-form-load-service:Facebook" id="postas-facebook" title="Facebook">
<span></span>
</a>
</li>
</ul>
</div>
<div id="comment-form-guest" class="comment-form-service selected">
<div class="comment-form-padder">
<div class="comment-form-avatar">
<a href="https://gravatar.com/site/signup/" target="_blank"> <img src="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&forcedefault=1&d=identicon" alt="Gravatar" width="25" class="no-grav" />
</a> </div>
<div class="comment-form-fields">
<div class="comment-form-field comment-form-email">
<label for="email">Email <span class="required">(required)</span> <span class="nopublish">(Address never made public)</span></label>
<div class="comment-form-input"><input id="email" name="email" type="text" value="" /></div>
</div>
<div class="comment-form-field comment-form-author">
<label for="author">Name <span class="required">(required)</span></label>
<div class="comment-form-input"><input id="author" name="author" type="text" value="" /></div>
</div>
<div class="comment-form-field comment-form-url">
<label for="url">Website</label>
<div class="comment-form-input"><input id="url" name="url" type="text" value="" /></div>
</div>
</div>
</div>
</div>
<div id="comment-form-wordpress" class="comment-form-service">
<div class="comment-form-padder">
<div class="comment-form-avatar">
<img src="http://s2.wp.com/wp-content/mu-plugins/highlander-comments/images/wplogo.png?m=1289230950g" alt="WordPress.com Logo" width="25" class="no-grav" />
</div>
<div class="comment-form-fields">
<input type="hidden" name="wp_avatar" id="wordpress-avatar" class="comment-meta-wordpress" value="" />
<input type="hidden" name="wp_user_id" id="wordpress-user_id" class="comment-meta-wordpress" value="" />
<input type="hidden" name="wp_access_token" id="wordpress-access_token" class="comment-meta-wordpress" value="" />
<p class="comment-form-posting-as pa-wordpress"><strong></strong> You are commenting using your WordPress.com account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'wordpress' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
</div>
</div>
</div>
<div id="comment-form-twitter" class="comment-form-service">
<div class="comment-form-padder">
<div class="comment-form-avatar">
<img src="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon" alt="Twitter picture" width="25" class="no-grav" />
</div>
<div class="comment-form-fields">
<input type="hidden" name="twitter_avatar" id="twitter-avatar" class="comment-meta-twitter" value="" />
<input type="hidden" name="twitter_user_id" id="twitter-user_id" class="comment-meta-twitter" value="" />
<input type="hidden" name="twitter_access_token" id="twitter-access_token" class="comment-meta-twitter" value="" />
<p class="comment-form-posting-as pa-twitter"><strong></strong> You are commenting using your Twitter account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'twitter' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
</div>
</div>
</div>
<div id="comment-form-facebook" class="comment-form-service">
<div class="comment-form-padder">
<div class="comment-form-avatar">
<img src="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon" alt="Facebook photo" width="25" class="no-grav" />
</div>
<div class="comment-form-fields">
<input type="hidden" name="fb_avatar" id="facebook-avatar" class="comment-meta-facebook" value="" />
<input type="hidden" name="fb_user_id" id="facebook-user_id" class="comment-meta-facebook" value="" />
<input type="hidden" name="fb_access_token" id="facebook-access_token" class="comment-meta-facebook" value="" />
<p class="comment-form-posting-as pa-facebook"><strong></strong> You are commenting using your Facebook account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'facebook' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
</div>
</div>
</div>
<div id="comment-form-load-service" class="comment-form-service">
<div class="comment-form-posting-as-cancel"><a href="javascript:HighlanderComments.cancelExternalWindow();">Cancel</a></div>
<p>Connecting to %s</p>
</div>
</div>
<div id="comment-form-subscribe">
<p class="comment-subscription-form"><input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" tabindex="6"/> <label class="subscribe-label" id="subscribe-label" for="subscribe">Notify me of follow-up comments via email.</label></p></div>
<script type="text/javascript">
jQuery(document).ready(function(){
// Expando Mode: start small, then auto-resize on first click + text length
jQuery( '#comment-form-identity' ).hide();
jQuery( '#comment-form-subscribe' ).hide();
jQuery( '#commentform .form-submit' ).hide();
jQuery( '#comment' ).css( { 'height':'10px' } ).one( 'focus', function() {
jQuery( this ).animate( { 'height':'70px' } );
jQuery( '#comment-form-identity' ).slideDown();
jQuery( '#comment-form-subscribe' ).slideDown();
jQuery( '#commentform .form-submit' ).slideDown();
});
});
</script>
<p class="form-submit">
<input name="submit" type="submit" id="comment-submit" value="Post Comment" />
<input type='hidden' name='comment_post_ID' value='372' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</p>
<input type="hidden" name="genseq" value="1336015328" />
<p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="35ad5f65a1" /></p><script type='text/javascript' src='http://s0.wp.com/wp-content/mu-plugins/akismet-2.5/form.js?m=1308783962g&#038;ver=1'></script>
<p style="display: none;"><input type="hidden" id="ak_js" name="ak_js" value="250"/></p> </form>
</div><!-- #respond -->
<div style="clear: both"></div>
</div> <!-- Close .comments container -->
</div>
<hr />
<ul class="secondary">
<li id="text-3" class="widget widget_text"> <div class="textwidget"><p>A Michigan Techie exploring Linux, Programming, and Woodworking. </p>
</div>
</li><li id="rss_links-2" class="widget widget_rss_links"><h2 class="widgettitle">RSS</h2>
<p class="size-small"><a class="feed-image-link" href="http://blog.mitechie.com/feed/" title="Subscribe to Posts"><img src="http://blog.mitechie.com/i/rss/orange-small.png" alt="RSS Feed" /></a>&nbsp;<a href="http://blog.mitechie.com/feed/" title="Subscribe to Posts">RSS - Posts</a></p><p class="size-small"><a class="feed-image-link" href="http://blog.mitechie.com/comments/feed/" title="Subscribe to Comments"><img src="http://blog.mitechie.com/i/rss/orange-small.png" alt="RSS Feed" /></a>&nbsp;<a href="http://blog.mitechie.com/comments/feed/" title="Subscribe to Comments">RSS - Comments</a></p>
</li><li id="linkcat-1356" class="widget widget_links"><h2 class="widgettitle">Blogroll</h2>
<ul class='xoxo blogroll'>
<li><a href="http://bmark.us" title="Delicious like bookmark application that&#8217;s open source" target="_blank">Bookie</a></li>
<li><a href="http://lococast.net" rel="me" title="My Podcast on Linux, Tech, Ubuntu Loco" target="_blank">Lococast.net</a></li>
<li><a href="http://www.mug.org/">Michigan Usr Group</a></li>
<li><a href="http://rick.bmark.us">My Bookmarks</a></li>
<li><a href="http://github.com/mitechie">My Github</a></li>
<li><a href="http://lococast.net/category/screencast" title="Some Vim Screencasts I do to help users that have figured out the basics of Vim and looking for some must have features." target="_blank">My Vim Screencasts</a></li>
<li><a href="http://ossmichigan.org/">OSS Michigan</a></li>
<li><a href="https://wiki.ubuntu.com/MichiganTeam">Ubuntu Michigan LoCo</a></li>
</ul>
</li>
<li id="wp_tag_cloud" class="widget wp_widget_tag_cloud"><h2 class="widgettitle">Tags</h2>
<div style="overflow:hidden"><a href='http://blog.mitechie.com/tag/accounts/' class='tag-link-4776' title='2 topics' style='font-size: 10.52pt;'>accounts</a>
<a href='http://blog.mitechie.com/tag/android/' class='tag-link-641922' title='1 topic' style='font-size: 8pt;'>android</a>
<a href='http://blog.mitechie.com/tag/api/' class='tag-link-4276' title='8 topics' style='font-size: 17.1pt;'>api</a>
<a href='http://blog.mitechie.com/tag/beanstalkd/' class='tag-link-14572501' title='1 topic' style='font-size: 8pt;'>beanstalkd</a>
<a href='http://blog.mitechie.com/tag/bmark-us/' class='tag-link-59219264' title='6 topics' style='font-size: 15.7pt;'>bmark.us</a>
<a href='http://blog.mitechie.com/tag/bookie-2/' class='tag-link-54482253' title='19 topics' style='font-size: 22pt;'>bookie</a>
<a href='http://blog.mitechie.com/tag/bookmarklet/' class='tag-link-9046' title='1 topic' style='font-size: 8pt;'>bookmarklet</a>
<a href='http://blog.mitechie.com/tag/bookmarks/' class='tag-link-4360' title='9 topics' style='font-size: 17.8pt;'>bookmarks</a>
<a href='http://blog.mitechie.com/tag/chc/' class='tag-link-351419' title='2 topics' style='font-size: 10.52pt;'>chc</a>
<a href='http://blog.mitechie.com/tag/chrome/' class='tag-link-367314' title='3 topics' style='font-size: 12.2pt;'>chrome</a>
<a href='http://blog.mitechie.com/tag/code-2/' class='tag-link-7689823' title='4 topics' style='font-size: 13.6pt;'>code</a>
<a href='http://blog.mitechie.com/tag/coders/' class='tag-link-1223867' title='1 topic' style='font-size: 8pt;'>coders</a>
<a href='http://blog.mitechie.com/tag/coffee/' class='tag-link-16166' title='1 topic' style='font-size: 8pt;'>coffee</a>
<a href='http://blog.mitechie.com/tag/coffeehousecoders/' class='tag-link-62715049' title='1 topic' style='font-size: 8pt;'>coffeehousecoders</a>
<a href='http://blog.mitechie.com/tag/community/' class='tag-link-2528' title='2 topics' style='font-size: 10.52pt;'>community</a>
<a href='http://blog.mitechie.com/tag/css/' class='tag-link-169' title='1 topic' style='font-size: 8pt;'>css</a>
<a href='http://blog.mitechie.com/tag/delicious/' class='tag-link-493' title='1 topic' style='font-size: 8pt;'>delicious</a>
<a href='http://blog.mitechie.com/tag/development/' class='tag-link-780' title='1 topic' style='font-size: 8pt;'>development</a>
<a href='http://blog.mitechie.com/tag/docs/' class='tag-link-10882' title='1 topic' style='font-size: 8pt;'>docs</a>
<a href='http://blog.mitechie.com/tag/extension/' class='tag-link-5024' title='3 topics' style='font-size: 12.2pt;'>extension</a>
<a href='http://blog.mitechie.com/tag/firefox/' class='tag-link-45' title='4 topics' style='font-size: 13.6pt;'>firefox</a>
<a href='http://blog.mitechie.com/tag/fulltext/' class='tag-link-666868' title='1 topic' style='font-size: 8pt;'>fulltext</a>
<a href='http://blog.mitechie.com/tag/javascript/' class='tag-link-457' title='10 topics' style='font-size: 18.36pt;'>javascript</a>
<a href='http://blog.mitechie.com/tag/jquery/' class='tag-link-203308' title='4 topics' style='font-size: 13.6pt;'>jquery</a>
<a href='http://blog.mitechie.com/tag/launchpad/' class='tag-link-110328' title='2 topics' style='font-size: 10.52pt;'>launchpad</a>
<a href='http://blog.mitechie.com/tag/mobile/' class='tag-link-120' title='1 topic' style='font-size: 8pt;'>mobile</a>
<a href='http://blog.mitechie.com/tag/nginx/' class='tag-link-697649' title='1 topic' style='font-size: 8pt;'>nginx</a>
<a href='http://blog.mitechie.com/tag/node-js/' class='tag-link-28224982' title='1 topic' style='font-size: 8pt;'>node.js</a>
<a href='http://blog.mitechie.com/tag/parser/' class='tag-link-47812' title='2 topics' style='font-size: 10.52pt;'>parser</a>
<a href='http://blog.mitechie.com/tag/penguicon/' class='tag-link-1001763' title='3 topics' style='font-size: 12.2pt;'>penguicon</a>
<a href='http://blog.mitechie.com/tag/profiling/' class='tag-link-29443' title='1 topic' style='font-size: 8pt;'>profiling</a>
<a href='http://blog.mitechie.com/tag/pylons/' class='tag-link-236456' title='3 topics' style='font-size: 12.2pt;'>pylons</a>
<a href='http://blog.mitechie.com/tag/pyohio/' class='tag-link-30987758' title='1 topic' style='font-size: 8pt;'>pyohio</a>
<a href='http://blog.mitechie.com/tag/pyramid/' class='tag-link-144718' title='3 topics' style='font-size: 12.2pt;'>pyramid</a>
<a href='http://blog.mitechie.com/tag/python/' class='tag-link-832' title='14 topics' style='font-size: 20.32pt;'>python</a>
<a href='http://blog.mitechie.com/tag/queue/' class='tag-link-369133' title='1 topic' style='font-size: 8pt;'>queue</a>
<a href='http://blog.mitechie.com/tag/ruby/' class='tag-link-4872' title='1 topic' style='font-size: 8pt;'>ruby</a>
<a href='http://blog.mitechie.com/tag/social/' class='tag-link-3457' title='1 topic' style='font-size: 8pt;'>social</a>
<a href='http://blog.mitechie.com/tag/sprint/' class='tag-link-22272' title='3 topics' style='font-size: 12.2pt;'>sprint</a>
<a href='http://blog.mitechie.com/tag/sqlalchemy/' class='tag-link-722763' title='6 topics' style='font-size: 15.7pt;'>sqlalchemy</a>
<a href='http://blog.mitechie.com/tag/sqlalchemy-migrate/' class='tag-link-33821937' title='1 topic' style='font-size: 8pt;'>sqlalchemy-migrate</a>
<a href='http://blog.mitechie.com/tag/status/' class='tag-link-577' title='2 topics' style='font-size: 10.52pt;'>status</a>
<a href='http://blog.mitechie.com/tag/testing/' class='tag-link-12' title='4 topics' style='font-size: 13.6pt;'>testing</a>
<a href='http://blog.mitechie.com/tag/turbogears/' class='tag-link-33610' title='1 topic' style='font-size: 8pt;'>turbogears</a>
<a href='http://blog.mitechie.com/tag/yui/' class='tag-link-202729' title='4 topics' style='font-size: 13.6pt;'>yui</a></div></li><li id="search-3" class="widget widget_search"><h2 class="widgettitle">Search</h2>
<form method="get" id="searchform" action="http://blog.mitechie.com/">
<div>
<input type="text" value="Search..." onfocus="if (this.value == 'Search...' ) { this.value = ''; }" onblur="if (this.value == '') { this.value = 'Search...';}" name="s" id="s" size="15" />
<input type="submit" id="searchsubmit" value="Go" />
</div>
</form></li></ul>
<div class="clear"></div>
</div>
<div style="clear:both;"></div>
</div>
<!-- Close Page -->
<div id="footer"><br /><hr />
<a href="http://wordpress.com/?ref=footer" rel="generator">Blog at WordPress.com</a>. &bull; Theme: <a href="http://theme.wordpress.com/themes/unsleepable/">Unsleepable</a> by <a href="http://www.openswitch.org" rel="designer">Ben Gray</a>. <a href="http://en.support.wordpress.com/custom-design/#custom-fonts" rel="external" title="Learn more about the fonts on this blog and the Custom Design upgrade">Fonts on this blog</a>.
</div>
<script type='text/javascript' src='http://s.gravatar.com/js/gprofiles.js?aa&#038;ver=3.4-beta3-20681'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var WPGroHo = {"my_hash":""};
/* ]]> */
</script>
<script type='text/javascript' src='http://s2.wp.com/wp-content/mu-plugins/gravatar-hovercards/wpgroho.js?m=1318621548g&#038;ver=3.4-beta3-20681'></script>
<script type="text/javascript">
var _qevents = _qevents || [], wpcomQuantcastData = {"qacct":"p-18-mFEk4J448M","labels":",language.en,type.wpcom,posttag.api,posttag.bookie-2,posttag.github,posttag.parser,posttag.penguicon,posttag.readability_lxml"};
function wpcomQuantcastPixel( labels, options ) {
var i, defaults = wpcomQuantcastData, data = { event: 'ajax' };
labels = labels || '';
options = options || {};
if ( typeof labels != 'string' )
options = labels;
for ( i in defaults ) {
data[i] = defaults[i];
}
for ( i in options ) {
data[i] = options[i];
}
if ( data.labels ) {
data.labels += ',' + labels;
} else {
data.labels = labels;
}
_qevents.push( data );
};
(function() {var elem = document.createElement('script');elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";elem.async = true;elem.type = "text/javascript";var scpt = document.getElementsByTagName('script')[0];scpt.parentNode.insertBefore(elem, scpt); })();
_qevents.push( wpcomQuantcastData );
</script>
<noscript><div style="display: none;"><img src="//pixel.quantserve.com/pixel/p-18-mFEk4J448M.gif?labels=%2Clanguage.en%2Ctype.wpcom%2Cposttag.api%2Cposttag.bookie-2%2Cposttag.github%2Cposttag.parser%2Cposttag.penguicon%2Cposttag.readability_lxml" height="1" width="1" alt="" /></div></noscript>
<script type="text/javascript">
/* <![CDATA[ */
(function($){
$(document).on( 'ready post-load', function() {
// Remove the login box when clicking the page
$( document ).mousedown( function( e ) {
if ( null == $( e.target ).closest( '#wpl-mustlogin' ).get( 0 ) ) {
$( '#wpl-mustlogin' ).remove();
}
});
// Handle clicking the like button itself
$('.wpl-button > a.like').click( function(e) {
e.preventDefault();
var postid = $(this).parent().attr('id').split('like-')[1];
$.post( 'http://blog.mitechie.com/wp-admin/admin-ajax.php', {
'action': 'wpl_record_stat',
'stat_name': 'loggedout_like_click'
} );
var tenMins = new Date();
tenMins.setTime( tenMins.getTime() + 600000 );
document.cookie = 'wpl_rand=27e9dbfee6; expires=' + tenMins.toGMTString() + '; domain=wordpress.com; path=/;';
$(this).parent().siblings('.wpl-count').after( '\
<div id="wpl-mustlogin"> \
<form action="https://mitechie.wordpress.com/wp-login.php" method="post"> \
<p>Just one more step to like this:</p> \
<label><span>Username</span> <input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="80" /></label> \
<label><span>Password</span> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="81" /></label> \
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="82" /> \
<input type="hidden" name="postid" value="' + postid + '" /> \
<input type="hidden" name="redirect_to" value="http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012?year=2012&monthnum=04&day=22&name=bookie-weekly-update-april-22nd-2012&like=1" /> \
<input type="hidden" name="wpl_rand" value="27e9dbfee6" /> \
<p>Not a member yet? <a href="http://wordpress.com/signup/?ref=likebox" id="wpl-signup-link">Sign up with WordPress.com</a></p> \
</form> \
</div> \
');
$('#wpl-mustlogin').hide().slideDown('fast');
} );
$('#wpl-mustlogin input.input').live( 'focus', function() {
$(this).prev().hide();
}).live( 'blur', function() {
if ( $(this).val() == '' ) {
$(this).prev().show();
}
});
$('#wpl-mustlogin input#wp-submit').live( 'click', function(e) {
e.preventDefault();
$.post( 'http://blog.mitechie.com/wp-admin/admin-ajax.php', {
'action': 'wpl_record_stat',
'stat_name': 'loggedout_login_submit'
}, function() {
$('#wpl-mustlogin form').submit();
} );
});
$('#wpl-mustlogin a#wpl-signup-link').live( 'click', function(e) {
e.preventDefault();
var link = $(this).attr('href');
$.post( 'http://blog.mitechie.com/wp-admin/admin-ajax.php', {
'action': 'wpl_record_stat',
'stat_name': 'loggedout_signup_click'
}, function() {
location.href = link;
} );
});
})
})(jQuery);
/* ]]> */
</script>
<script>jQuery(document).ready(function($){ Gravatar.profile_cb = function( h, d ) { WPGroHo.syncProfileData( h, d ); }; Gravatar.my_hash = WPGroHo.my_hash; Gravatar.init( 'body', '#wp-admin-bar-my-account' ); });</script> <div style="display:none">
</div>
<style type="text/css">
.reblog-from img { margin: 0 10px 0 0; vertical-align: middle; padding: 0; border: 0; }
.reblogger-note img.avatar { float: left; padding: 0; border: 0; }
.reblogger-note-content { margin: 0 0 20px 35px; }
.reblog-post { border-left: 3px solid #eee; padding-left: 15px; }
.reblog-post ul.thumb-list { display: block; list-style: none; margin: 2px 0; padding: 0; clear: both; }
.reblog-post ul.thumb-list li { display: inline; margin: 0; padding: 0 1px; border: 0; }
.reblog-post ul.thumb-list li a { margin: 0; padding: 0; border: 0; }
.reblog-post ul.thumb-list li img { margin: 0; padding: 0; border: 0; }
.reblog-post { border-left: 3px solid #eee; padding-left: 15px; }
.reblog-post .wpcom-enhanced-excerpt { clear: both; }
.reblog-post .wpcom-enhanced-excerpt address,
.reblog-post .wpcom-enhanced-excerpt li,
.reblog-post .wpcom-enhanced-excerpt h1,
.reblog-post .wpcom-enhanced-excerpt h2,
.reblog-post .wpcom-enhanced-excerpt h3,
.reblog-post .wpcom-enhanced-excerpt h4,
.reblog-post .wpcom-enhanced-excerpt h5,
.reblog-post .wpcom-enhanced-excerpt h6,
.reblog-post .wpcom-enhanced-excerpt p { font-size: 100% !important; }
.reblog-post .wpcom-enhanced-excerpt blockquote,
.reblog-post .wpcom-enhanced-excerpt pre,
.reblog-post .wpcom-enhanced-excerpt code,
.reblog-post .wpcom-enhanced-excerpt q { font-size: 98% !important; }
</style><script type='text/javascript'>
/* <![CDATA[ */
var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1$s: You are commenting using your %2$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"http:\/\/mitechie.wordpress.com\/public.api\/connect\/?action=request","logoutURL":"http:\/\/mitechie.wordpress.com\/wp-login.php?action=logout&_wpnonce=b3f903a3dd","homeURL":"http:\/\/blog.mitechie.com\/","postID":"372","gravDefault":"identicon","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"0","userIsLoggedIn":""};
/* ]]> */
</script>
<script type='text/javascript' src='http://s1.wp.com/wp-content/mu-plugins/highlander-comments/script.js?m=1334861972g&#038;ver=20110804'></script>
<div id="bit" class="loggedout-follow-normal">
<a class="bsub" href="javascript:void(0)"><span id='bsub-text'>Follow</span></a>
<div id="bitsubscribe">
<h3><label for="loggedout-follow-field">Follow &ldquo;Tech Rantings from a Michigan Techie&rdquo;</label></h3>
<form action="https://subscribe.wordpress.com" method="post" accept-charset="utf-8" id="loggedout-follow">
<p>Get every new post delivered to your Inbox.</p>
<p id="loggedout-follow-error" style="display: none;"></p>
<p><input type="text" name="email" style="width: 95%; padding: 1px 2px" value="Enter your email address" onfocus='this.value=(this.value=="Enter your email address") ? "" : this.value;' onblur='this.value=(this.value=="") ? "Enter email address" : this.value;' id="loggedout-follow-field"/></p>
<input type="hidden" name="action" value="subscribe"/>
<input type="hidden" name="blog_id" value="11465279"/>
<input type="hidden" name="source" value="http://blog.mitechie.com/2012/04/22/bookie-weekly-update-april-22nd-2012/"/>
<input type="hidden" name="sub-type" value="loggedout-follow"/>
<input type="hidden" id="_wpnonce" name="_wpnonce" value="f253f56d33" /><input type="hidden" name="_wp_http_referer" value="/2012/04/22/bookie-weekly-update-april-22nd-2012/" />
<p id='bsub-subscribe-button'><input type="submit" value="Sign me up" /></p>
</form>
<div id='bsub-credit'><a href="http://wordpress.com/signup/?ref=lof">Powered by WordPress.com</a></div>
</div><!-- #bitsubscribe -->
</div><!-- #bit -->
<script type="text/javascript" src="http://b.scorecardresearch.com/beacon.js"></script><script type="text/javascript">try{COMSCORE.beacon({c1:2,c2:7518284});}catch(e){}</script><noscript><p class="robots-nocontent"><img src="http://b.scorecardresearch.com/p?cj=1c1=2&#038;c2=7518284" alt="" style="display:none" width="1" height="1" /></p></noscript><script type="text/javascript">
// <![CDATA[
(function() {
try{
if ( window.external &&'msIsSiteMode' in window.external) {
if (window.external.msIsSiteMode()) {
var jl = document.createElement('script');
jl.type='text/javascript';
jl.async=true;
jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(jl, s);
}
}
}catch(e){}
})();
// ]]>
</script><script src="http://s.stats.wordpress.com/w.js?21" type="text/javascript"></script>
<script type="text/javascript">
st_go({'blog':'11465279','v':'wpcom','user_id':'0','post':'372','subd':'mitechie'});
ex_go({'crypt':'UE40eW5QN0p8M2Y/RE1TaVhzUzFMbjdWNHpwZGhTayxPSUFCMGNrd29+Smw0c2YrNHNBSkw3cVdPUTNiUmUvRG9WajdULixdZiZQQnVGbEV1K2E/MyUucUFSZT8xc2JFN094NjdGTGo4NC9DUDkwSXJ1RS1PbC44SkxidkRmWUo3c21idFhrcW03Qlt8dyZYcjlvPXBuWEo9OXVJczBuU0txTn5CQz1ySHpxbUt0SmJGUXk9PUJZR3JPNlZqSW1zK2VlXTAuamx+LU5QdU5yN1g2X0FuYVRwbF95TXpubGEvRUY9Smg9ci8vSEU3bWp1bnJUZHorM3NBVlkwUlNSeGFUSC9zNjFRSnMzPS5wci5NXX5JRVJYNl9PT1FKaXlKQ3lCRTJvSWQ/XXRVMHZyeGlhNiZYcD1WPTUwNGZHdXZaLWdHYkRUTE9SWw=='});
addLoadEvent(function(){linktracker_init('11465279',372);});
</script>
<noscript><img src="http://stats.wordpress.com/b.gif?v=noscript" style="height:0px;width:0px;overflow:hidden" alt="" /></noscript>
</body>
</html>
Loading…
Cancel
Save