<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;A08HRX0zfSp7ImA9WhBbEUQ.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762</id><updated>2013-05-10T18:30:34.385+03:00</updated><category term="logging" /><category term="flash" /><category term="styling" /><category term="installing" /><category term="tools" /><category term="package" /><category term="1.5" /><category term="Time Capsule" /><category term="super" /><category term="Machine" /><category term="dd" /><category term="bug" /><category term="bugs" /><category term="production" /><category term="free" /><category term="uploads" /><category term="development" /><category term="HttpResponseRedirect" /><category term="simpletag" /><category term="new" /><category term="UI" /><category term="pretty" /><category term="privacy" /><category term="migrate" /><category term="interfaces" /><category term="regexp" /><category term="measure" /><category term="Apple" /><category term="assignment_tag" /><category term="upgrade" /><category term="query" /><category term="put" /><category term="iteration" /><category term="Skype" /><category term="truncate" /><category term="restore" /><category term="inheritance" /><category term="TDD" /><category term="push" /><category term="configuration" /><category term="git" /><category term="not" /><category term="email" /><category term="unicode" /><category term="developer" /><category term="redirect" /><category term="iOS" /><category term="ordinal not in range" /><category term="sort" /><category term="django-password-reset" /><category term="sh" /><category term="scripting" /><category term="POST" /><category term="system" /><category term="Time Machine" /><category term="hdd" /><category term="type" /><category term="ssd" /><category term="macfuse" /><category term="ntfs" /><category term="authentication" /><category term="in" /><category term="commit" /><category term="field" /><category term="contacts" /><category term="ordinal not in range(128)" /><category term="trim" /><category term="etc" /><category term="autorun" /><category term="django" /><category term="OSX" /><category term="HFS+" /><category term="pdf" /><category term="multiupload" /><category term="controll" /><category term="rotate" /><category term="execution" /><category term="djago" /><category term="iterable" /><category term="iPhone" /><category term="iTunes" /><category term="1.4" /><category term="view" /><category term="DB" /><category term="django-log-file-viewer" /><category term="mac" /><category term="power" /><category term="ManyRelatedManager" /><category term="sort()" /><category term="network" /><category term="ereader" /><category term="syncdb" /><category term="datetime" /><category term="project" /><category term="disable" /><category term="error" /><category term="jailbreak" /><category term="compiler" /><category term="disable local backups" /><category term="google" /><category term="dependencies" /><category term="space" /><category term="paspberry" /><category term="Unix" /><category term="PIL" /><category term="re" /><category term="dejavu" /><category term="smtp" /><category term="Microsoft" /><category term="support" /><category term="templatetag" /><category term="month" /><category term="list" /><category term="client" /><category term="drive" /><category term="PYTHONPATH" /><category term="pi" /><category term="add" /><category term="need" /><category term="github" /><category term="__init__" /><category term="caddy" /><category term="tag" /><category term="auth" /><category term="preferences" /><category term="ports" /><category term="compact" /><category term="command" /><category term="template" /><category term="IDE" /><category term="demo" /><category term="OS X" /><category term="GUI" /><category term="Cydia" /><category term="green" /><category term="response" /><category term="year" /><category term="opensource" /><category term="plugin" /><category term="saving" /><category term="access" /><category term="image" /><category term="code" /><category term="JSON" /><category term="virtualenv" /><category term="Facebook" /><category term="manual" /><category term="share" /><category term="multiple files" /><category term="hack" /><category term="router" /><category term="init" /><category term="operation" /><category term="docs" /><category term="boot" /><category term="basic" /><category term="login" /><category term="usb" /><category term="connect" /><category term="howto" /><category term="parse" /><category term="readme" /><category term="PyCharm" /><category term="deployment" /><category term="remote" /><category term="oplayer" /><category term="files" /><category term="django-compress" /><category term="migration" /><category term="better" /><category term="ssh" /><category term="CSV" /><category term="version" /><category term="+1" /><category term="button" /><category term="raspberry pi" /><category term="create" /><category term="tar" /><category term="private" /><category term="regex" /><category term="jquery" /><category term="egit" /><category term="tuple" /><category term="transfer" /><category term="recipe" /><category term="clone" /><category term="Linux" /><category term="django-compressor" /><category term="twitter" /><category term="log" /><category term="samba" /><category term="server" /><category term="'ascii' codec can't encode character" /><category term="goodreader" /><category term="paginate" /><category term="webassets" /><category term="Connection refused" /><category term="recursively" /><category term="problem" /><category term="queryset" /><category term="install" /><category term="visual" /><category term="templates" /><category term="netatalk" /><category term="installation" /><category term="south" /><category term="initialize" /><category term="web" /><category term="encoding" /><category term="characters" /><category term="pip" /><category term="HttpResponse" /><category term="storage" /><category term="finder" /><category term="method" /><category term="settings" /><category term="Mountain Lion" /><category term="unitest" /><category term="grant" /><category term="date" /><category term="localhost" /><category term="upgrading" /><category term="m2m" /><category term="test" /><category term="sshfs" /><category term="decision" /><category term="css" /><category term="render" /><category term="js" /><category term="fabric" /><category term="iPhoto" /><category term="migrations" /><category term="link" /><category term="app" /><category term="time mashine" /><category term="scp" /><category term="Raspbery" /><category term="eclipse" /><category term="hdparm" /><category term="generate" /><category term="backup" /><category term="__init__.py" /><category term="freetype" /><category term="snippets" /><category term="Lion" /><category term="jpeg" /><category term="os" /><category term="object" /><category term="models" /><category term="manage" /><category term="unauthorized" /><category term="needs" /><category term="sendmail" /><category term="bash" /><category term="thumbnail" /><category term="move" /><category term="user" /><category term="filter" /><category term="CouchDB" /><category term="style" /><category term="interpreter" /><category term="timezone" /><category term="contrib" /><category term="pypi" /><category term="dev" /><category term="place" /><category term="testing" /><category term="release" /><category term="redundancy" /><category term="automation" /><category term="serialize" /><category term="nice" /><category term="django-pagination" /><category term="compressor" /><category term="garmoncheg" /><category term="raspberry" /><category term="setup" /><category term="aware" /><category term="set up" /><category term="url" /><category term="csrf" /><category term="enable" /><category term="javascript" /><category term="Errno 61" /><category term="debugging" /><category term="resolv.conf" /><category term="migrating" /><category term="rm" /><category term="UTC" /><category term="AJAX" /><category term="environment" /><category term="directory" /><category term="gzip" /><category term="runserver" /><category term="form" /><category term="UnicodeEncodeError" /><category term="AFP" /><category term="ImageField" /><category term="compression" /><category term="console" /><category term="pyc" /><category term="straightforward" /><category term="find" /><category term="download" /><category term="archive" /><category term="approach" /><category term="PyDev" /><category term="python" /><category term="official" /><category term="browser" /><category term="Linkedin" /><category term="class" /><category term="script" /><category term="versions" /><category term="range" /><category term="forms" /><category term="windows" /><category term="tweak" /><category term="file" /><category term="timezones" /><category term="django-registration" /><category term="solve" /><category term="database" /><category term="stage" /><category term="debug" /><category term="unittests" /><category term="snippet" /><category term="element" /><category term="demon" /><category term="old" /><category term="translation" /><category term="patterns" /><category term="templatetags" /><category term="dateutil" /><category term="static" /><category term="programming" /><category term="DebuggingServer" /><category term="tutorial" /><category term="reset" /><category term="execute" /><category term="configure" /><category term="card" /><category term="name" /><category term="ContactPrivacy" /><category term="simple" /><category term="smtplib" /><category term="blog" /><category term="ascii" /><category term="config" /><category term="FileField" /><category term="signals" /><category term="constructor" /><category term="time" /><category term="kindle" /><category term="source" /><category term="pagination" /><category term="staticfiles" /><category term="mode" /><category term="tags" /><category term="terminal" /><category term="ordinal" /><category term="dictionary" /><category term="features" /><category term="pattern" /><category term="token" /><category term="tagging" /><category term="iPad" /><category term="model" /><category term="WD" /><category term="data" /><category term="password" /><category term="second drive" /><category term="clean" /><title>Programmer blog</title><subtitle type="html">My thoughts/recipes on Django, Python, JS and other things I try...</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://garmoncheg.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/WebProgrammerBlog" /><feedburner:info uri="webprogrammerblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DUEFQHY8fSp7ImA9WhBVGE0.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-7906970166073841951</id><published>2013-04-24T15:46:00.001+03:00</published><updated>2013-04-24T15:46:51.875+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-24T15:46:51.875+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="version" /><category scheme="http://www.blogger.com/atom/ns#" term="tags" /><category scheme="http://www.blogger.com/atom/ns#" term="tagging" /><category scheme="http://www.blogger.com/atom/ns#" term="tag" /><category scheme="http://www.blogger.com/atom/ns#" term="git" /><category scheme="http://www.blogger.com/atom/ns#" term="commit" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="project" /><category scheme="http://www.blogger.com/atom/ns#" term="push" /><title>Git tag and versioning your project</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
We use tags to version our project. I will set up here basic commands we use on everyday basis and may use to handle some issues.&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Showing your tags&lt;/h4&gt;
Listing the available tags in Git is straightforward. Just type&lt;b&gt; git tag&lt;/b&gt;.&lt;br /&gt;
&lt;table border="0" style="font-family: sans-serif; width: 100%px;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign="top" width="45%"&gt;&lt;div style="overflow: auto;"&gt;
&lt;pre style="background-color: #001800; background-position: initial initial; background-repeat: initial initial; color: #55cc66;"&gt;&lt;pre&gt;$ git tag
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;7&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;8&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;9&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Adding tags&lt;/h4&gt;
To add tags you may do &lt;b&gt;git tag &lt;i&gt;tagname&lt;/i&gt;&lt;/b&gt;. But better to specify args to be able to use in scripts:&lt;br /&gt;
&lt;table border="0" style="font-family: sans-serif; width: 100%px;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign="top" width="45%"&gt;&lt;div style="overflow: auto;"&gt;
&lt;pre style="background-color: #001800; background-position: initial initial; background-repeat: initial initial; color: #55cc66;"&gt;&lt;pre&gt;$ git tag &lt;span style="color: #808030;"&gt;-&lt;/span&gt;a &lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;m &lt;span style="color: #cc5555;"&gt;"major improvements"&lt;/span&gt;
$ git tag
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;7&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;8&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;9&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;0&lt;/span&gt;
&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Here we have added a tag version &lt;i&gt;1.1.1&lt;/i&gt; with commit message &lt;i&gt;"major improvements"&lt;/i&gt;.&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Uploading to repository&lt;/h4&gt;
I assume you have a GitHub repo. So to push your tags there run git push (for your tagged commits commits) and then push your tags:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: sans-serif; overflow: auto;"&gt;
&lt;pre style="background-color: #001800; background-position: initial initial; background-repeat: initial initial; color: #55cc66;"&gt;&lt;pre&gt;$ git push
Counting objects&lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #778c77;"&gt;120&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; done.
Delta compression using up to &lt;span style="color: #778c77;"&gt;4&lt;/span&gt; threads.
Compressing objects&lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #778c77;"&gt;100&lt;/span&gt;% &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #778c77;"&gt;59&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #778c77;"&gt;59&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; done.
Writing objects&lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #778c77;"&gt;100&lt;/span&gt;% &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #778c77;"&gt;69&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #778c77;"&gt;69&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #778c77;"&gt;390&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;70&lt;/span&gt; KiB&lt;span style="color: #808030;"&gt;,&lt;/span&gt; done.
Total &lt;span style="color: #778c77;"&gt;69&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;delta &lt;span style="color: #778c77;"&gt;41&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; reused &lt;span style="color: #778c77;"&gt;0&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;delta &lt;span style="color: #778c77;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
To ****************.git
   ******..******  master &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; master
$ git push &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;tags
Counting objects&lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; done.
Writing objects&lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #778c77;"&gt;100&lt;/span&gt;% &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #778c77;"&gt;157&lt;/span&gt; bytes&lt;span style="color: #808030;"&gt;,&lt;/span&gt; done.
Total &lt;span style="color: #778c77;"&gt;1&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;delta &lt;span style="color: #778c77;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; reused &lt;span style="color: #778c77;"&gt;0&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;delta &lt;span style="color: #778c77;"&gt;0&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
To ****************.git
 * &lt;span style="color: #808030;"&gt;[&lt;/span&gt;new tag&lt;span style="color: #808030;"&gt;]&lt;/span&gt;         &lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;.&lt;span style="color: #778c77;"&gt;1&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; major improvements&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You may now check this is pushed by clicking your GitHub repo's Tags button.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-iX8mfl2u43o/UXfTaMNLh6I/AAAAAAAAFg0/k7BdXUs-Fws/s1600/Screen+Shot+2013-04-24+at+3.42.09+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-iX8mfl2u43o/UXfTaMNLh6I/AAAAAAAAFg0/k7BdXUs-Fws/s1600/Screen+Shot+2013-04-24+at+3.42.09+PM.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Removing a Tag&lt;/h4&gt;
In case you have pushed a wrong tag... For example, if you have created a tag called &lt;b&gt;push&lt;/b&gt;&amp;nbsp;in a Git repository you would remove it from your repository by doing the following:&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;pre style="color: #55cc66;"&gt;&lt;table border="0" style="font-family: sans-serif; width: 100%px;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign="top" width="45%"&gt;&lt;div style="overflow: auto;"&gt;
&lt;pre style="background-color: #001800; background-position: initial initial; background-repeat: initial initial; color: #55cc66;"&gt;&lt;pre&gt;git tag &lt;span style="color: #808030;"&gt;-&lt;/span&gt;d push
git push origin &lt;span style="color: #808030;"&gt;:&lt;/span&gt;refs&lt;span style="color: #808030;"&gt;/&lt;/span&gt;tags&lt;span style="color: #808030;"&gt;/&lt;/span&gt;push&lt;/pre&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Now it's up to you to handle it in a release/deployment/staging/whatever script. Hope it helps. Besides, this should handle 99% of your tasks with tags. If not feel free to use &lt;a href="http://git-scm.com/book/en/Git-Basics-Tagging"&gt;official docs&lt;/a&gt; ;)&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Comments and suggestions are welcome.&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/DHzFf964hw0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/7906970166073841951/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2013/04/git-tag-and-versioning-your-project.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/7906970166073841951?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/7906970166073841951?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/DHzFf964hw0/git-tag-and-versioning-your-project.html" title="Git tag and versioning your project" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-iX8mfl2u43o/UXfTaMNLh6I/AAAAAAAAFg0/k7BdXUs-Fws/s72-c/Screen+Shot+2013-04-24+at+3.42.09+PM.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://garmoncheg.blogspot.com/2013/04/git-tag-and-versioning-your-project.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUACQng7fSp7ImA9WhBWEEU.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-1510181988552836398</id><published>2013-04-04T17:58:00.001+03:00</published><updated>2013-04-04T18:02:43.605+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-04T18:02:43.605+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="templatetag" /><category scheme="http://www.blogger.com/atom/ns#" term="bash" /><category scheme="http://www.blogger.com/atom/ns#" term="snippets" /><category scheme="http://www.blogger.com/atom/ns#" term="tag" /><category scheme="http://www.blogger.com/atom/ns#" term="upgrade" /><category scheme="http://www.blogger.com/atom/ns#" term="templates" /><category scheme="http://www.blogger.com/atom/ns#" term="snippet" /><category scheme="http://www.blogger.com/atom/ns#" term="url" /><category scheme="http://www.blogger.com/atom/ns#" term="migration" /><category scheme="http://www.blogger.com/atom/ns#" term="1.5" /><category scheme="http://www.blogger.com/atom/ns#" term="migrating" /><category scheme="http://www.blogger.com/atom/ns#" term="command" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>Django 1.5 migrating to new url tag syntax</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-g3YLrNVBCdI/TgC6dzQgXdI/AAAAAAAAEX0/WaYzohgqQLQ/s1600/django_full.jpeg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="90" src="http://3.bp.blogspot.com/-g3YLrNVBCdI/TgC6dzQgXdI/AAAAAAAAEX0/WaYzohgqQLQ/s200/django_full.jpeg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
Django 1.5 changed. The url tag syntax from &lt;b&gt;{% url &amp;nbsp;my_page %}&lt;/b&gt; into &lt;b&gt;{% url "my_page" %}&lt;/b&gt;. Now all my templates should be changed accordingly to migrate to 1.5. You could do it with executing this command in your bash shell.&lt;br /&gt;
Assuming you are in the project folder. Assuming you have version control, or do know how to backup your work ;). Some people claim it is unsafe. But you may want to make it safer with adding&lt;b&gt; '{%'&lt;/b&gt; to the beginning of the string. To make sure only templates arre changed. Or either execute this only in your templates folder to be sure.&lt;br /&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;$ find &lt;span style="color: #808030;"&gt;.&lt;/span&gt; &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;type&lt;/span&gt; f &lt;span style="color: #808030;"&gt;-&lt;/span&gt;print0 &lt;span style="color: #808030;"&gt;|&lt;/span&gt; xargs &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #778c77;"&gt;0&lt;/span&gt; sed &lt;span style="color: #808030;"&gt;-&lt;/span&gt;i &lt;span style="color: #cc5555;"&gt;'s/ url \([^" &amp;gt;][^ &amp;gt;]*\)/ url "\1"/g'&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
And one person did a django snippet for this operation. You may also find it useful.&amp;nbsp;&lt;a href="http://djangosnippets.org/snippets/2905/"&gt;http://djangosnippets.org/snippets/2905/&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/AXORrvz49Cg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/1510181988552836398/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2013/04/django-15-migrating-to-new-url-tag.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1510181988552836398?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1510181988552836398?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/AXORrvz49Cg/django-15-migrating-to-new-url-tag.html" title="Django 1.5 migrating to new url tag syntax" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-g3YLrNVBCdI/TgC6dzQgXdI/AAAAAAAAEX0/WaYzohgqQLQ/s72-c/django_full.jpeg" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Lutsk, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.74723299999999 25.325382999999988</georss:point><georss:box>50.74723299999999 25.325382999999988 50.74723299999999 25.325382999999988</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2013/04/django-15-migrating-to-new-url-tag.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEAFQnkyeyp7ImA9WhBSEU0.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-7558562194848620914</id><published>2013-02-17T14:05:00.003+02:00</published><updated>2013-02-17T14:05:13.793+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-17T14:05:13.793+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="server" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="bash" /><category scheme="http://www.blogger.com/atom/ns#" term="redundancy" /><category scheme="http://www.blogger.com/atom/ns#" term="installation" /><category scheme="http://www.blogger.com/atom/ns#" term="fabric" /><category scheme="http://www.blogger.com/atom/ns#" term="web" /><category scheme="http://www.blogger.com/atom/ns#" term="scripting" /><category scheme="http://www.blogger.com/atom/ns#" term="stage" /><category scheme="http://www.blogger.com/atom/ns#" term="deployment" /><category scheme="http://www.blogger.com/atom/ns#" term="production" /><category scheme="http://www.blogger.com/atom/ns#" term="pip" /><category scheme="http://www.blogger.com/atom/ns#" term="automation" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>Automating everyday system routine with Fabric (Python)</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-26tDKDBx4FE/USDHYTJ26vI/AAAAAAAAFgY/w01vXbxx5Zg/s1600/21.jpeg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="196" src="http://2.bp.blogspot.com/-26tDKDBx4FE/USDHYTJ26vI/AAAAAAAAFgY/w01vXbxx5Zg/s200/21.jpeg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Lets talk about your console work. I use it on everyday basis. I need to log on to &amp;nbsp;my deployment/stage/whatever, server and do some redundancy. E.g. download some logs, clean up some caches and/or redeploy something. Here is the occasion, when&amp;nbsp;&lt;a href="http://docs.fabfile.org/en/1.5/"&gt;Fabric&lt;/a&gt;&amp;nbsp;comes handy. You can eliminate all the redundancy and cover tons of operations you need to do every day, using console,&amp;nbsp;shortcutting&amp;nbsp;them to one of your simple commands, like:&amp;nbsp;&lt;b&gt;fab deploy_production -H root@mydeployment.com&amp;nbsp;&lt;/b&gt;interested? Let's move on then. Notie this command is not a masterpiece, but must give you the understanding of usual workflow.&lt;br /&gt;
&lt;h3&gt;
&lt;b&gt;1. Installation and purposes&lt;/b&gt;&lt;/h3&gt;
Let's go ahead, installing Fabric and automating some simple operations. You can read&amp;nbsp;&lt;a href="http://docs.fabfile.org/en/1.5/"&gt;official docs&lt;/a&gt;&amp;nbsp;about alternative methods. But installation is&amp;nbsp;fairly&amp;nbsp;simple. And is the matter of typing:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;$pip install fabric&lt;/pre&gt;
&lt;br /&gt;
Nothing more special is required. You will need fabric at system wide scale. I install it locally with superuser privilegies. Note I'm assuming installation of this on my MacBook and not on a production server or any remote&amp;nbsp;destination. Fabric really is a shell wrapper with commands&amp;nbsp;queue&amp;nbsp;that executes your console tasks. Something similar to Django unit tests, if you know what I mean. E.g. Developing a fabric script is a process of copy-paste your console interactions and here you go... Similar to BASH/SH scripts. But why use fabric then?&lt;br /&gt;
&lt;br /&gt;
How would you handle commands exit status in shell or bash? Write some error handling right? And this one comes out of the box with it ;)&lt;br /&gt;
Let's not just talk, but write some&lt;br /&gt;
&lt;h3&gt;
2. Example usage&lt;/h3&gt;
To write your commands you need to make a file called&amp;nbsp;&lt;b&gt;fabfile.py&lt;/b&gt;&amp;nbsp;with syntax that is described in fabric documentation. But it's almost "pure" python. So everything must be understood easily.&lt;br /&gt;
&lt;br /&gt;
Fabric supports all the python stuff. And good IMHO practice it to split your task to steps and execute them one by one. You can use &lt;b&gt;def&lt;/b&gt; method to define them. E.g.:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #b96969;"&gt;"""Test script for article"""&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;from&lt;/span&gt; fabric&lt;span style="color: #808030;"&gt;.&lt;/span&gt;api &lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; run

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; set_up&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""does some setup automation"""&lt;/span&gt;
    run&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'setup something'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; run&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""main run method, that now calls set_up() method"""&lt;/span&gt;
    set_up&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Now you can run a command &lt;b&gt;fab --list&lt;/b&gt; in this directory. Output will be like so. Note how it converted all your comments into handy help text explanation for your script.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;leopard-&lt;span style="color: #778c77;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;article garmon$ fab --list
Test script &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; article

Available commands&lt;span style="color: #808030;"&gt;:&lt;/span&gt;

    run     main run method, that now calls set_up&lt;span style="color: purple;"&gt;(&lt;/span&gt;&lt;span style="color: purple;"&gt;)&lt;/span&gt; method
    set_up  does some setup automation
leopard-&lt;span style="color: #778c77;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;article garmon$&lt;/pre&gt;
&lt;br /&gt;
Now we have got a handy script to setup something. But let's not get away with it and show you some real life example. It will also be converted to hide some (possible) sensitive information...&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
3. Real life example&lt;/h3&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #b96969;"&gt;"""Example script for article with deployment parts"""&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;from&lt;/span&gt; fabric&lt;span style="color: #808030;"&gt;.&lt;/span&gt;api &lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; run&lt;span style="color: #808030;"&gt;,&lt;/span&gt; sudo&lt;span style="color: #808030;"&gt;,&lt;/span&gt; cd&lt;span style="color: #808030;"&gt;,&lt;/span&gt; get&lt;span style="color: #808030;"&gt;,&lt;/span&gt; local&lt;span style="color: #808030;"&gt;,&lt;/span&gt; lcd&lt;span style="color: #808030;"&gt;,&lt;/span&gt; prefix

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; cleanup_environment&lt;span style="color: #808030;"&gt;(&lt;/span&gt;folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;""" deletes old deployment instance"""&lt;/span&gt;
    sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'rm -rf %s'&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt; folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; install&lt;span style="color: #808030;"&gt;(&lt;/span&gt;folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;""" Installs an instance of my website into production deployment server with recreating a virtual environment"""&lt;/span&gt;
    with cd&lt;span style="color: #808030;"&gt;(&lt;/span&gt;folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'virtualenv ve --no-site-packages'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    with prefix&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'source %sve/bin/activate'&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt; folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'pip install mysite'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; restart&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""Restarts a service of my website"""&lt;/span&gt;
    sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'service mysite restart'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; stop&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""Stops a service of my website"""&lt;/span&gt;
    sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'service mysite stop'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; run&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""Runs a service of my website"""&lt;/span&gt;
    sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'service mysite run'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; download_logs&lt;span style="color: #808030;"&gt;(&lt;/span&gt;folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;""" Download logs files and db from server to local machine current directory&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;This will download all the logs from deployment server&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;into your current directory (locally) with current timestamp"""&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; datetime
    time_stamp &lt;span style="color: #808030;"&gt;=&lt;/span&gt; datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;strftime&lt;span style="color: #808030;"&gt;(&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;now&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;"%Y-%m-%d-%HH-%MM-%SS"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    with cd&lt;span style="color: #808030;"&gt;(&lt;/span&gt;folder_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'tar -czvf /tmp/dms_logs.tgz ./log/dms.log*'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; user&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'user'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    local&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'mkdir ./%s/'&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt; time_stamp&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    with lcd&lt;span style="color: #808030;"&gt;(&lt;/span&gt;time_stamp&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        get&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"/tmp/dms_logs.tgz"&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;"./dms_logs.tgz"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        local&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"tar -xzvf dms_logs.tgz"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        local&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"rm -f dms_logs.tgz"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    sudo&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"rm -f /tmp/dms_logs.tgz"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; main&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""Redeploy your Django powered website"""&lt;/span&gt;
    deployment_path &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'/srv/www/django'&lt;/span&gt;
    download_logs&lt;span style="color: #808030;"&gt;(&lt;/span&gt;deployment_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    stop&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    cleanup_environment&lt;span style="color: #808030;"&gt;(&lt;/span&gt;deployment_path&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    install&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    run&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
This script has main commands for me to run make redeployment of my website into a production web server, with archiving all the data (logs in this example) into a directory with current timestamp.&lt;br /&gt;
&lt;br /&gt;
You must run it with a parameter &lt;b&gt;-H&lt;/b&gt; specified. this&amp;nbsp;parameter&amp;nbsp;represents a host that our little script will ssh to. and is something like &lt;b&gt;username@192.168.1.1&lt;/b&gt;, or something you can ssh to, using command &lt;b&gt;ssh&lt;/b&gt;. E.g.&lt;b&gt; -H stage-server&lt;/b&gt; in case you can locally type &lt;b&gt;ssh stage-server&lt;/b&gt;. So the full command to run this will be something like: &lt;b&gt;fab main -H my_deployment_server&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Most fo the code in this script is given as an example. And may contain some logical errors, because it is taken from different parts of a real life deployment commands. But I really hope it will help you to master your own deployment with this handy tool.&lt;br /&gt;
&lt;br /&gt;
Comments and suggestions are welcome...&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/APJYaV1YVuk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/7558562194848620914/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2013/02/automating-everyday-system-routine-with.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/7558562194848620914?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/7558562194848620914?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/APJYaV1YVuk/automating-everyday-system-routine-with.html" title="Automating everyday system routine with Fabric (Python)" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-26tDKDBx4FE/USDHYTJ26vI/AAAAAAAAFgY/w01vXbxx5Zg/s72-c/21.jpeg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://garmoncheg.blogspot.com/2013/02/automating-everyday-system-routine-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQHQX87fCp7ImA9WhNUE0w.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-2579051616341380092</id><published>2013-01-04T17:28:00.001+02:00</published><updated>2013-01-04T17:28:50.104+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-04T17:28:50.104+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="autorun" /><category scheme="http://www.blogger.com/atom/ns#" term="sh" /><category scheme="http://www.blogger.com/atom/ns#" term="raspberry" /><category scheme="http://www.blogger.com/atom/ns#" term="execute" /><category scheme="http://www.blogger.com/atom/ns#" term="pi" /><category scheme="http://www.blogger.com/atom/ns#" term="hdparm" /><category scheme="http://www.blogger.com/atom/ns#" term="command" /><category scheme="http://www.blogger.com/atom/ns#" term="system" /><category scheme="http://www.blogger.com/atom/ns#" term="script" /><category scheme="http://www.blogger.com/atom/ns#" term="boot" /><title>Raspberry Pi boot applications Autorun</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" /&gt;&lt;/a&gt;&lt;/div&gt;
I had a problem with running required programs upon system startup. I had to set up &lt;b&gt;hdparm&lt;/b&gt; utility each time system boots up. I have 2 external HDD's connected and require setting their sleep time for 10 minutes each boot. So setting this up. The answer is found at Debian administration guides. &amp;nbsp;I'll provide it in the end of the article. Here is my&amp;nbsp;decision&amp;nbsp;based on that:&lt;br /&gt;
&lt;br /&gt;
So to set up a program to run on system boot. (In&amp;nbsp;fact&amp;nbsp;one of the system&amp;nbsp;run-levels). You can add it's name. But a good practice will be to add an&amp;nbsp;&lt;b&gt;sh&lt;/b&gt; script with execution of this utility an all the parameters.&lt;br /&gt;
Sample script is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #595979;"&gt;#! &lt;/span&gt;&lt;span style="color: #007997;"&gt;/bin/sh&lt;/span&gt;
&lt;span style="color: #595979;"&gt;# /etc/init.d/blah&lt;/span&gt;
&lt;span style="color: #595979;"&gt;#&lt;/span&gt;

&lt;span style="color: #595979;"&gt;# Some things that run always&lt;/span&gt;
touch &lt;span style="color: #40015a;"&gt;/var/lock/blah&lt;/span&gt;

&lt;span style="color: #595979;"&gt;# Carry out specific functions when asked to by the system&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;case&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"&lt;/span&gt;&lt;span style="color: #007d45;"&gt;$1&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;in&lt;/span&gt;
  start&lt;span style="color: #e34adc;"&gt;)&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Starting script blah "&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Could do more here"&lt;/span&gt;
    &lt;span style="color: #e34adc;"&gt;;;&lt;/span&gt;
  stop&lt;span style="color: #e34adc;"&gt;)&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Stopping script blah"&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Could do more here"&lt;/span&gt;
    &lt;span style="color: #e34adc;"&gt;;;&lt;/span&gt;
  &lt;span style="color: #308080;"&gt;*&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;)&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Usage: &lt;/span&gt;&lt;span style="color: #40015a;"&gt;/etc/init.d/blah&lt;/span&gt;&lt;span style="color: #1060b6;"&gt; {start|stop}"&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;exit&lt;/span&gt; &lt;span style="color: #008c00;"&gt;1&lt;/span&gt;
    &lt;span style="color: #e34adc;"&gt;;;&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;esac&lt;/span&gt;

&lt;span style="color: #7779bb; font-weight: bold;"&gt;exit&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
You can insert your utility name instead of "blah" and give it a spin. My script looked like:&lt;br /&gt;
And make sure it is owned by root user:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;sudo chmod &lt;span style="color: #008c00;"&gt;755&lt;/span&gt; &lt;span style="color: #40015a;"&gt;/etc/init.d/blah&lt;/span&gt;
sudo chown root&lt;span style="color: #308080;"&gt;:&lt;/span&gt;root &lt;span style="color: #40015a;"&gt;/etc/init.d/blah&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
So my script began to look like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #595979;"&gt;#! &lt;/span&gt;&lt;span style="color: #007997;"&gt;/bin/sh&lt;/span&gt;
&lt;span style="color: #595979;"&gt;# /etc/init.d/hdparams&lt;/span&gt;
&lt;span style="color: #595979;"&gt;#&lt;/span&gt;

&lt;span style="color: #595979;"&gt;# Carry out specific functions when asked to by the system&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;case&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"&lt;/span&gt;&lt;span style="color: #007d45;"&gt;$1&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;in&lt;/span&gt;
  start&lt;span style="color: #e34adc;"&gt;)&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Setting Connected HDD sleep timeout to 10 Minutes."&lt;/span&gt;
    hdparm &lt;span style="color: #44aadd;"&gt;-S&lt;/span&gt; &lt;span style="color: #008c00;"&gt;120&lt;/span&gt; &lt;span style="color: #40015a;"&gt;/dev/sda1&lt;/span&gt;
    hdparm &lt;span style="color: #44aadd;"&gt;-S&lt;/span&gt; &lt;span style="color: #008c00;"&gt;120&lt;/span&gt; &lt;span style="color: #40015a;"&gt;/dev/sdb1&lt;/span&gt;
    &lt;span style="color: #e34adc;"&gt;;;&lt;/span&gt;
  stop&lt;span style="color: #e34adc;"&gt;)&lt;/span&gt;
    &lt;span style="color: #e34adc;"&gt;;;&lt;/span&gt;
  &lt;span style="color: #308080;"&gt;*&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;)&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;echo&lt;/span&gt; &lt;span style="color: #1060b6;"&gt;"Usage: &lt;/span&gt;&lt;span style="color: #40015a;"&gt;/etc/init.d/hdparams&lt;/span&gt;&lt;span style="color: #1060b6;"&gt; {start|stop}"&lt;/span&gt;
    &lt;span style="color: #7779bb; font-weight: bold;"&gt;exit&lt;/span&gt; &lt;span style="color: #008c00;"&gt;1&lt;/span&gt;
    &lt;span style="color: #e34adc;"&gt;;;&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;esac&lt;/span&gt;

&lt;span style="color: #7779bb; font-weight: bold;"&gt;exit&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Because I really don't care about hdd spin down time at shut down and/or system reboot.&lt;br /&gt;
Original article is:&amp;nbsp;&lt;a href="http://www.debian-administration.org/articles/28"&gt;http://www.debian-administration.org/articles/28&lt;/a&gt;&lt;br /&gt;
Hope it helped somebody. Please comment if you used/found some inconsistency...&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/VWAqcpvzSpg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/2579051616341380092/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2013/01/raspberry-pi-boot-applications-autorun.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2579051616341380092?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2579051616341380092?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/VWAqcpvzSpg/raspberry-pi-boot-applications-autorun.html" title="Raspberry Pi boot applications Autorun" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s72-c/Screen+Shot+2012-11-10+at+4.44.47+PM.png" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.74723299999999 25.325382999999988</georss:point><georss:box>50.666856999999986 25.164021499999986 50.82760899999999 25.48674449999999</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2013/01/raspberry-pi-boot-applications-autorun.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEFQ3Yzeyp7ImA9WhNVGEQ.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-4694447909442900068</id><published>2012-12-30T21:10:00.001+02:00</published><updated>2012-12-30T21:10:12.883+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-30T21:10:12.883+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="server" /><category scheme="http://www.blogger.com/atom/ns#" term="share" /><category scheme="http://www.blogger.com/atom/ns#" term="paspberry" /><category scheme="http://www.blogger.com/atom/ns#" term="iPad" /><category scheme="http://www.blogger.com/atom/ns#" term="iPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="oplayer" /><category scheme="http://www.blogger.com/atom/ns#" term="samba" /><category scheme="http://www.blogger.com/atom/ns#" term="windows" /><category scheme="http://www.blogger.com/atom/ns#" term="connect" /><category scheme="http://www.blogger.com/atom/ns#" term="usb" /><category scheme="http://www.blogger.com/atom/ns#" term="install" /><category scheme="http://www.blogger.com/atom/ns#" term="OS X" /><category scheme="http://www.blogger.com/atom/ns#" term="ntfs" /><category scheme="http://www.blogger.com/atom/ns#" term="file" /><category scheme="http://www.blogger.com/atom/ns#" term="goodreader" /><category scheme="http://www.blogger.com/atom/ns#" term="mac" /><category scheme="http://www.blogger.com/atom/ns#" term="storage" /><category scheme="http://www.blogger.com/atom/ns#" term="drive" /><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi" /><title>Raspbery Pi as a home file server</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" /&gt;&lt;/a&gt;&lt;/div&gt;
I've wanted more from my PI, besides Time Machine functions, established in my earlier articles. So I've decided to make it a SAMBA server. I have a Mac and a Windows PC. And several iPads/iPhones. So the decision was obvious. To access my storage content I'd need a samba share. Because it is recognized by all this tech. iPad has Oplayer, to watch movies without conversion... GoodReader for docs. One word - SAMBA share. SO this article will be about adding a samba share to your Raspberry Pi.&lt;br /&gt;
Note I have a Time Machine already set up. But it won't matter much. I only have another drive index letters and so on. I'll try to cover this as much as possible. And macs somewhat easily read NTFS filesystems. So we will be mounting NTFS filesystem volume to a Raspberry Pi with SAMBA network sharing. Let's get on to it.&lt;br /&gt;
&lt;br /&gt;
To set up a Raspbery Pi home network Samba server you will need to:&lt;br /&gt;
&lt;i&gt;- Connect an external drive (USB HDD in my case).&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;- Update fstab for auto-mounting of it on system boot&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;- Install and configure samba&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;- Enjoy&lt;/i&gt;&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
1. Connecting an external USB drive.&lt;/h3&gt;
&lt;div&gt;
Assuming you hava an external hard drive connected type the command:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ sudo blkid
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;mmcblk0p1&lt;span style="color: #406080;"&gt;:&lt;/span&gt; SEC_TYPE&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;msdos&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;XXXX_XXXX&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; TYPE&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;vfat&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; 
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;mmcblk0p2&lt;span style="color: #406080;"&gt;:&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;XXXXXX_XXXXXX_XXXXX_XXXX&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; TYPE&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;ext4&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; 
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1&lt;span style="color: #406080;"&gt;:&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;XXXXXXX-XXXXXXX-XXXXXXX-XXXXX&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; LABEL&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;Time Machine&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; TYPE&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;hfsplus&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; 
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sdb1&lt;span style="color: #406080;"&gt;:&lt;/span&gt; LABEL&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;Data1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;5XXXXXXXXXX1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; TYPE&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;ntfs&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Note I have &lt;b&gt;sda1&lt;/b&gt; drive with hfsplus filesystem for AFP shares so my NTFS drive is named &lt;b&gt;sdb1. &lt;/b&gt;Yours will probably be sda1 out of the box. Note that. We now see the NTFS hdd. Lets make it mounted. Typing &lt;b&gt;mount&lt;/b&gt; command will show it's not yet there.&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ mount
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;root on &lt;span style="color: #308080;"&gt;/&lt;/span&gt; type ext4 &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;user_xattr&lt;span style="color: #308080;"&gt;,&lt;/span&gt;barrier&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;data&lt;span style="color: #308080;"&gt;=&lt;/span&gt;ordered&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
&lt;span style="color: #004a43;"&gt;# &lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1 on &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine type hfsplus &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nodev&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;umask&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;uid&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;gid&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nls&lt;span style="color: #308080;"&gt;=&lt;/span&gt;utf8&lt;span style="color: #308080;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
2.&amp;nbsp;Update fstab for auto-mounting of it on system boot&lt;/h3&gt;
&lt;div&gt;
Lets make a directory for mounting a drive:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ sudo mkdir &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;data&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Now lets update fstab to add a setting for proper auto-mount of our drive on boot.&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ sudo nano &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;fstab&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Lets add a line. Something like.&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;XXXXXXXXXXXXXX&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;data ntfs rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;auto&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Where UUID is your device UUID, that you can find out using &lt;b&gt;sudo blkid&lt;/b&gt; command.&lt;/div&gt;
&lt;div&gt;
Now we can either reboot or mount a hard drive. I choose to mount. Lets type:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ sudo mount &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sdb1
pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ mount
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;root on &lt;span style="color: #308080;"&gt;/&lt;/span&gt; type ext4 &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;user_xattr&lt;span style="color: #308080;"&gt;,&lt;/span&gt;barrier&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;data&lt;span style="color: #308080;"&gt;=&lt;/span&gt;ordered&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
&lt;span style="color: #004a43;"&gt;# &lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sdb1 on &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;data type fuseblk &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nodev&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;user_id&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;group_id&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;allow_other&lt;span style="color: #308080;"&gt;,&lt;/span&gt;blksize&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;4096&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
And our drive is mounted and will be auto-mounted on each reboot.&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
3. Install samba&lt;/h3&gt;
&lt;div&gt;
Now lets move on to installing samba server for our network sharing. Lets do it with &lt;b&gt;apt-get&lt;/b&gt;:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ sudo apt&lt;span style="color: #308080;"&gt;-&lt;/span&gt;get install samba&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Confirm additional package downloads by typing &lt;b&gt;y&lt;/b&gt;&amp;nbsp;to the prompt of this command. And wait while it installs some demons and defaults.&lt;/div&gt;
&lt;div&gt;
Now lets edit the default samba config:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt $ sudo nano &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;samba&lt;span style="color: #308080;"&gt;/&lt;/span&gt;smb&lt;span style="color: #308080;"&gt;.&lt;/span&gt;conf&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
And add the config of our drive to the end of this config file. (After numerous other parameters):&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #308080;"&gt;[&lt;/span&gt;Data&lt;span style="color: #308080;"&gt;]&lt;/span&gt;
comment &lt;span style="color: #308080;"&gt;=&lt;/span&gt; DataDrive
read only &lt;span style="color: #308080;"&gt;=&lt;/span&gt; no
locking &lt;span style="color: #308080;"&gt;=&lt;/span&gt; no
path &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;data     
guest ok &lt;span style="color: #308080;"&gt;=&lt;/span&gt; yes
force user &lt;span style="color: #308080;"&gt;=&lt;/span&gt; pi&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
After this is done simple restart of samba server will be sufficient:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt;&lt;span style="color: #308080;"&gt;~&lt;/span&gt;$ sudo service samba restart&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h3 style="text-align: left;"&gt;
4. Enjoy&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
Now I have a file dump server I ever dreamed of. I can connect as guest with all my devices and have a cross platform decision built on a PI platform.&lt;/div&gt;
&lt;div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-1LAgQAuVTsM/UOCNVFwCTXI/AAAAAAAAFfQ/_D2RnYFtj4U/s1600/Screen+Shot+2012-12-30+at+8.51.16+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://2.bp.blogspot.com/-1LAgQAuVTsM/UOCNVFwCTXI/AAAAAAAAFfQ/_D2RnYFtj4U/s640/Screen+Shot+2012-12-30+at+8.51.16+PM.png" width="606" /&gt;&lt;/a&gt;&lt;/div&gt;
And this all stuff looks like this now. With a second ntfs external HDD and my Pi in Punnet MK1 paper case.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-76rc-hWX0v8/UOCQE-ZlWcI/AAAAAAAAFfk/lRnrR4brRyo/s1600/Screen+Shot+2012-12-30+at+9.03.10+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="328" src="http://2.bp.blogspot.com/-76rc-hWX0v8/UOCQE-ZlWcI/AAAAAAAAFfk/lRnrR4brRyo/s640/Screen+Shot+2012-12-30+at+9.03.10+PM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/bzxc3GCSdrg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/4694447909442900068/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/12/raspbery-pi-as-home-file-server.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4694447909442900068?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4694447909442900068?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/bzxc3GCSdrg/raspbery-pi-as-home-file-server.html" title="Raspbery Pi as a home file server" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s72-c/Screen+Shot+2012-11-10+at+4.44.47+PM.png" height="72" width="72" /><thr:total>3</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.74723299999999 25.325382999999988</georss:point><georss:box>50.666856999999986 25.164021499999986 50.82760899999999 25.48674449999999</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/12/raspbery-pi-as-home-file-server.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMDQHo5fip7ImA9WhNUE0w.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-1050903759772486886</id><published>2012-11-27T19:45:00.003+02:00</published><updated>2013-01-04T17:31:11.426+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-04T17:31:11.426+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Time Capsule" /><category scheme="http://www.blogger.com/atom/ns#" term="power" /><category scheme="http://www.blogger.com/atom/ns#" term="raspberry" /><category scheme="http://www.blogger.com/atom/ns#" term="pi" /><category scheme="http://www.blogger.com/atom/ns#" term="mode" /><category scheme="http://www.blogger.com/atom/ns#" term="hdparm" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="WD" /><category scheme="http://www.blogger.com/atom/ns#" term="hdd" /><category scheme="http://www.blogger.com/atom/ns#" term="saving" /><category scheme="http://www.blogger.com/atom/ns#" term="green" /><title>Raspbery Pi Time Capsule HDD managing power saving mode</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: right;"&gt;
&lt;a href="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" /&gt;&lt;/a&gt;&lt;/div&gt;
I want to sugest power saving changes after installing and handling creation of Time Capsule for Time Machine for my home network (&lt;a href="http://garmoncheg.blogspot.com/2012/11/time-capsule-for-25.html"&gt;form my previous article&lt;/a&gt;). I like when it's quiet. And like when disks does not spin, when it's&lt;span style="color: red;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;not necessary to do so. So if you usually backup once in some hours and main time (Night and a part of the day) you do not touch a Time Machine... You would probably want to slow down your disks for that time.&amp;nbsp;Fortunately&amp;nbsp;Linux does it very well. And support of it is encoded into Linux core (kernel). You just would need a UI for this possibilities and a bit of knowledge and luck ;)&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
Warning: Operations described farther may be&amp;nbsp;potentially&amp;nbsp;hazardous to your hardware.&lt;/h3&gt;
So now after you are warned ;) let's continue. I guess I will not touch those hazardous functions, but you may, typing wrong letters to this command in Linux shell... So be&amp;nbsp;careful. Better read manuals for farther commands and so on...&lt;br /&gt;
&lt;br /&gt;
Anyway what we need is a UI. And we have it in form of nice utility called &lt;b&gt;hdparm&lt;/b&gt;. It is not included in current Raspbian distribution (and it should not be perhaps) so you would probably need to install it by yourself. In fact you can find a package with it. But I'd recommend installing from latest version. It is&amp;nbsp;&lt;a href="http://hdparm.sourceforge.net/"&gt;http://hdparm.sourceforge.net/&lt;/a&gt; situated. You can download it there. Using &lt;b&gt;wget&lt;/b&gt;, for e.g. So move on to&amp;nbsp;downloading&amp;nbsp;and unpacking it. If you have a default Raspbian kernel, or did not screw up something useful while configuring and compiling your on one... You would probably simply enter a directory and type&amp;nbsp;something&amp;nbsp;like this:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ wget http&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #308080;"&gt;/&lt;/span&gt;&lt;span style="color: #308080;"&gt;/&lt;/span&gt;switch.dl.sourceforge.&lt;span style="color: #200080; font-weight: bold;"&gt;net&lt;/span&gt;&lt;span style="color: #308080;"&gt;/&lt;/span&gt;project&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt;.tar.gz
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ tar &lt;span style="color: #308080;"&gt;-&lt;/span&gt;zxvf hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt;.tar.gz
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ &lt;span style="color: #200080; font-weight: bold;"&gt;cd&lt;/span&gt; hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt;
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt; $ .&lt;span style="color: #308080;"&gt;/&lt;/span&gt;configure
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt; $ make
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt; $ sudo make &lt;span style="color: #200080; font-weight: bold;"&gt;install&lt;/span&gt;
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;hdparm&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;9&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt; $ hdparm

hdparm &lt;span style="color: #308080;"&gt;-&lt;/span&gt; get&lt;span style="color: #308080;"&gt;/&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;set&lt;/span&gt; hard disk parameters &lt;span style="color: #308080;"&gt;-&lt;/span&gt; version v9.&lt;span style="color: #008c00;"&gt;43&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt; by Mark Lord.

Usage&lt;span style="color: #308080;"&gt;:&lt;/span&gt;  hdparm  &lt;span style="color: #308080;"&gt;[&lt;/span&gt;options&lt;span style="color: #308080;"&gt;]&lt;/span&gt; &lt;span style="color: #308080;"&gt;[&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;device&lt;/span&gt; ...&lt;span style="color: #308080;"&gt;]&lt;/span&gt;

Options&lt;span style="color: #308080;"&gt;:&lt;/span&gt;
...&lt;/pre&gt;
Hurray! we have our desired utility. Reading through it's help you would probably find a useful for us paramether:&amp;nbsp;&lt;b&gt;&amp;nbsp;-S &amp;nbsp; Set standby (spindown) timeout&lt;/b&gt;&lt;br /&gt;
Here is our goal.&amp;nbsp;I've set mine to 120 (10 minutes) by executing:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo hdparm &lt;span style="color: #308080;"&gt;-&lt;/span&gt;S &lt;span style="color: #008c00;"&gt;120&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1

&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1&lt;span style="color: #308080;"&gt;:&lt;/span&gt;
 setting standby to &lt;span style="color: #008c00;"&gt;120&lt;/span&gt; &lt;span style="color: #308080;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;10&lt;/span&gt; minutes&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $&lt;/pre&gt;
I have a WD "green" drive and will benefit from this. But you may harm your drive with often&amp;nbsp;standbys&amp;nbsp;and spinups. So choose wisely and read &lt;b&gt;man hdparm &lt;/b&gt;for more ;).&lt;br /&gt;
Hope you would&amp;nbsp;benefit&amp;nbsp;from my finding. Please comment in either way.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;UPD: &lt;/b&gt;to persist this upon boots see article:&lt;br /&gt;
&lt;a href="http://garmoncheg.blogspot.com/2013/01/raspberry-pi-boot-applications-autorun.html"&gt;http://garmoncheg.blogspot.com/2013/01/raspberry-pi-boot-applications-autorun.html&lt;/a&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/Mz-WmbPE2SA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/1050903759772486886/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/11/raspbery-pi-time-capsule-hdd-managing.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1050903759772486886?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1050903759772486886?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/Mz-WmbPE2SA/raspbery-pi-time-capsule-hdd-managing.html" title="Raspbery Pi Time Capsule HDD managing power saving mode" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s72-c/Screen+Shot+2012-11-10+at+4.44.47+PM.png" height="72" width="72" /><thr:total>4</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.666856 25.167454499999998 50.82761 25.4833115</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/11/raspbery-pi-time-capsule-hdd-managing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cMRXs_eip7ImA9WhNVEEo.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-1941916590997192663</id><published>2012-11-27T19:06:00.002+02:00</published><updated>2012-12-21T10:38:04.542+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-21T10:38:04.542+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="server" /><category scheme="http://www.blogger.com/atom/ns#" term="Time Capsule" /><category scheme="http://www.blogger.com/atom/ns#" term="AFP" /><category scheme="http://www.blogger.com/atom/ns#" term="Mountain Lion" /><category scheme="http://www.blogger.com/atom/ns#" term="configure" /><category scheme="http://www.blogger.com/atom/ns#" term="HFS+" /><category scheme="http://www.blogger.com/atom/ns#" term="network" /><category scheme="http://www.blogger.com/atom/ns#" term="pi" /><category scheme="http://www.blogger.com/atom/ns#" term="demon" /><category scheme="http://www.blogger.com/atom/ns#" term="time" /><category scheme="http://www.blogger.com/atom/ns#" term="Raspbery" /><category scheme="http://www.blogger.com/atom/ns#" term="Time Machine" /><category scheme="http://www.blogger.com/atom/ns#" term="Machine" /><category scheme="http://www.blogger.com/atom/ns#" term="set up" /><category scheme="http://www.blogger.com/atom/ns#" term="netatalk" /><category scheme="http://www.blogger.com/atom/ns#" term="backup" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="mac" /><category scheme="http://www.blogger.com/atom/ns#" term="Lion" /><title>Time Capsule for $25</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
The real article name might be something like:&amp;nbsp;&lt;i&gt;Configuring Raspbery Pi to serve like a Time Capsule with Netatalk 3.0 for Mountain Lion. &lt;/i&gt;&amp;nbsp;But it's too long ;)&lt;/h3&gt;
Here I will describe the process of using &lt;a href="http://www.raspberrypi.org/"&gt;Raspberry Pi&lt;/a&gt; like a Time Machine in my network. To be able to backup your MAC's remotely (Like it would be NAS of some kind). It assumes you have a &lt;a href="http://www.raspberrypi.org/"&gt;Raspberry Pi&lt;/a&gt; and have installed a Raspbian there and have a ssh connection, or somehow having access to it's console. &lt;a href="http://garmoncheg.blogspot.com/2012/11/raspberry-pi-first-steps-and-basic.html"&gt;Refer to my previous article for details&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Now that we have a Pi that is ready for action let's animate it. So to make it suit you as a Time Capsule (NAS) for your MAC's you need to do those basic steps:&lt;br /&gt;
- connect and configure USB hard drive(s)&lt;br /&gt;
- install support of HFS+ filesystem to be able to use MAC's native filesystem&lt;br /&gt;
- make mount (auto-mount on boot) of your hard drive&lt;br /&gt;
- install Avahi and Netatalk demons&lt;br /&gt;
- configure Netatalk daemon to make it all serve as a Time Machine&lt;br /&gt;
- configure avahi demon&lt;br /&gt;
- put avahi and netatalk demons into autolaunch on system boot&lt;br /&gt;
- ENJOY.&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
1. Setup a Hard drive.&lt;/h3&gt;
I assume you know what you are doing and understand you have to have a hard drive formatted under your mac's HFS+ filesystem. That you, like me, used as an external hard drive for backups before this. Just for example. Or bought it... Whatever. One word you will need (or assume you have) an external USB drive to follow me farther.&lt;br /&gt;
&lt;br /&gt;
Start your drive (in case it has external power). I think Pi would handle only drives with external power. But who knows ;). And connect it to your Pi. Let it spin for some seconds to be&amp;nbsp;recognized.&lt;br /&gt;
Now connect to console of your Pi and let's roll.&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;leopard$ ssh pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;&lt;span style="color: #008c00;"&gt;192&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;168&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;140&lt;/span&gt;
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;&lt;span style="color: #008c00;"&gt;192&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;168&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;140&lt;/span&gt;'s password&lt;span style="color: #308080;"&gt;:&lt;/span&gt; 
Linux raspberrypi &lt;span style="color: #008c00;"&gt;3&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;2&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;27&lt;/span&gt;+ #&lt;span style="color: #008c00;"&gt;250&lt;/span&gt; PREEMPT Thu Oct &lt;span style="color: #008c00;"&gt;18&lt;/span&gt; &lt;span style="color: #008c00;"&gt;19&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;03&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;02&lt;/span&gt; BST &lt;span style="color: #008c00;"&gt;2012&lt;/span&gt; armv6l

The programs included with the Debian GNU&lt;span style="color: #308080;"&gt;/&lt;/span&gt;Linux system are free software&lt;span style="color: #308080;"&gt;;&lt;/span&gt;
the exact distribution terms &lt;span style="color: #200080; font-weight: bold;"&gt;for&lt;/span&gt; each program are described &lt;span style="color: #200080; font-weight: bold;"&gt;in&lt;/span&gt; the
individual &lt;span style="color: #200080; font-weight: bold;"&gt;files&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;in&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;usr&lt;span style="color: #308080;"&gt;/&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;share&lt;/span&gt;&lt;span style="color: #308080;"&gt;/&lt;/span&gt;doc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;*&lt;span style="color: #308080;"&gt;/&lt;/span&gt;copyright.

Debian GNU&lt;span style="color: #308080;"&gt;/&lt;/span&gt;Linux comes with ABSOLUTELY NO WARRANTY&lt;span style="color: #308080;"&gt;,&lt;/span&gt; to the extent
permitted by applicable law.
Last login&lt;span style="color: #308080;"&gt;:&lt;/span&gt; Mon Oct &lt;span style="color: #008c00;"&gt;29&lt;/span&gt; &lt;span style="color: #008c00;"&gt;01&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;04&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;39&lt;/span&gt; &lt;span style="color: #008c00;"&gt;2012&lt;/span&gt;
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $&lt;/pre&gt;
As you can see I have a clean system installed from latest (as for 24.11.2012) downloaded image.&lt;br /&gt;
&lt;br /&gt;
Let's do some magic. Because Raspbian does not support Apple's filesystem out of the box. At least we need to mount it write enabled. Which is not set up by default too. SO let's start from typing command &lt;b&gt;blkid &lt;/b&gt;under root&amp;nbsp;and looking at output.&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo blkid
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;mmcblk0p1&lt;span style="color: #308080;"&gt;:&lt;/span&gt; SEC_TYPE&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"msdos"&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"8B12-9112"&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;TYPE&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"vfat"&lt;/span&gt; 
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;mmcblk0p2&lt;span style="color: #308080;"&gt;:&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"AAAAAAA-1111-1111-......."&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;TYPE&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"ext4"&lt;/span&gt; 
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1&lt;span style="color: #308080;"&gt;:&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"AAAAAAA-1111-1111-......."&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;LABEL&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"Time Machine"&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;TYPE&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"hfsplus"&lt;/span&gt; 
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda2&lt;span style="color: #308080;"&gt;:&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;LABEL&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"Data"&lt;/span&gt; UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"1234567890......."&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;TYPE&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"ntfs"&lt;/span&gt; 
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $&lt;/pre&gt;
Note UUID of your device. Mine is called &lt;b&gt;sda1&lt;/b&gt; and has a partition type &lt;b&gt;hfsplus&lt;/b&gt;. &amp;nbsp;Hurray! Drive is connected and is&amp;nbsp;recognized&amp;nbsp;by Pi.&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
2. Install support of AFP filesystem (MAC's native).&lt;/h3&gt;
Now let's install tools we need for HFS+ filesystem mounting. We need &amp;nbsp;to mount it RW to be able to backup.&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo apt&lt;span style="color: #308080;"&gt;-&lt;/span&gt;get &lt;span style="color: #200080; font-weight: bold;"&gt;install&lt;/span&gt; hfsplus hfsutils hfsprogs&lt;/pre&gt;
Press &lt;b&gt;"y"&lt;/b&gt; in the process of install. You will get HFS+ support libraries installed. So let's move on to mounting.&lt;br /&gt;
After this you should be able to mount your HDD. You may try it or skip to making permanent mounting config via &lt;b&gt;/etc/fstab&lt;/b&gt; (Step 3).&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo mount &lt;span style="color: #308080;"&gt;-&lt;/span&gt;o force &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1 &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ &lt;span style="color: #200080; font-weight: bold;"&gt;cd&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine $ ls &lt;span style="color: #308080;"&gt;-&lt;/span&gt;l
total &lt;span style="color: #008c00;"&gt;116&lt;/span&gt;
drwxr&lt;span style="color: #308080;"&gt;-&lt;/span&gt;xr&lt;span style="color: #308080;"&gt;-&lt;/span&gt;x &lt;span style="color: #008c00;"&gt;1&lt;/span&gt; root      &lt;span style="color: #008c00;"&gt;99&lt;/span&gt;      &lt;span style="color: #008c00;"&gt;6&lt;/span&gt; Jan &lt;span style="color: #008c00;"&gt;11&lt;/span&gt;  &lt;span style="color: #008c00;"&gt;2012&lt;/span&gt; Backups.backupdb
drwxrwxrwx &lt;span style="color: #008c00;"&gt;1&lt;/span&gt;  &lt;span style="color: #008c00;"&gt;501&lt;/span&gt; dialout     &lt;span style="color: #008c00;"&gt;31&lt;/span&gt; Feb  &lt;span style="color: #008c00;"&gt;1&lt;/span&gt;  &lt;span style="color: #008c00;"&gt;2012&lt;/span&gt; !DVD&lt;span style="color: #308080;"&gt;-&lt;/span&gt;s
&lt;span style="color: #308080;"&gt;-&lt;/span&gt;rwxr&lt;span style="color: #308080;"&gt;-&lt;/span&gt;xr&lt;span style="color: #308080;"&gt;-&lt;/span&gt;x &lt;span style="color: #008c00;"&gt;1&lt;/span&gt; root root    &lt;span style="color: #008c00;"&gt;115716&lt;/span&gt; Sep  &lt;span style="color: #008c00;"&gt;1&lt;/span&gt; &lt;span style="color: #008c00;"&gt;07&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;23&lt;/span&gt; tmbootpicker.efi
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine $&lt;/pre&gt;
You may see your files from a HDD. Hurray! Again ;). Btw you can look at how is your device was mounted by typing &lt;b&gt;mount &lt;/b&gt;command into prompt. It will show your mounted volume and mode it was mounted. So you will see something like this:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine $ mount
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;root &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; ext4 &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;user_xattr&lt;span style="color: #308080;"&gt;,&lt;/span&gt;barrier&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;data&lt;span style="color: #308080;"&gt;=&lt;/span&gt;ordered&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
devtmpfs &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; devtmpfs &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;size&lt;span style="color: #308080;"&gt;=&lt;/span&gt;118872k&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nr_inodes&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;29718&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;mode&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;755&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
tmpfs &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;run &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; tmpfs &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;size&lt;span style="color: #308080;"&gt;=&lt;/span&gt;23788k&lt;span style="color: #308080;"&gt;,&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;mode&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;755&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
tmpfs &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;run&lt;span style="color: #308080;"&gt;/&lt;/span&gt;lock &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; tmpfs &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nodev&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;size&lt;span style="color: #308080;"&gt;=&lt;/span&gt;5120k&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
proc &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;proc &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; proc &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nodev&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
sysfs &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;sys &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; sysfs &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nodev&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
tmpfs &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;run&lt;span style="color: #308080;"&gt;/&lt;/span&gt;shm &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; tmpfs &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nodev&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;size&lt;span style="color: #308080;"&gt;=&lt;/span&gt;47560k&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
devpts &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;pts &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; devpts &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nosuid&lt;span style="color: #308080;"&gt;,&lt;/span&gt;noexec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;gid&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;5&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;mode&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;620&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;mmcblk0p1 &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;boot &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; vfat &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;fmask&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0022&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;dmask&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0022&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;codepage&lt;/span&gt;&lt;span style="color: #308080;"&gt;=&lt;/span&gt;cp437&lt;span style="color: #308080;"&gt;,&lt;/span&gt;iocharset&lt;span style="color: #308080;"&gt;=&lt;/span&gt;ascii&lt;span style="color: #308080;"&gt;,&lt;/span&gt;shortname&lt;span style="color: #308080;"&gt;=&lt;/span&gt;mixed&lt;span style="color: #308080;"&gt;,&lt;/span&gt;errors&lt;span style="color: #308080;"&gt;=&lt;/span&gt;remount&lt;span style="color: #308080;"&gt;-&lt;/span&gt;ro&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
&lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1 &lt;span style="color: #200080; font-weight: bold;"&gt;on&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine &lt;span style="color: #200080; font-weight: bold;"&gt;type&lt;/span&gt; hfsplus &lt;span style="color: #308080;"&gt;(&lt;/span&gt;rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;relatime&lt;span style="color: #308080;"&gt;,&lt;/span&gt;umask&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;22&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;uid&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;gid&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;nls&lt;span style="color: #308080;"&gt;=&lt;/span&gt;utf8&lt;span style="color: #308080;"&gt;)&lt;/span&gt;&lt;/pre&gt;
Note last line with &lt;b&gt;/dev/sda1&lt;/b&gt; mounted in mode &lt;b&gt;"rw"&lt;/b&gt;. Yes everything works well. Let's move on.&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
3. Make mount (auto-mount on boot) of your hard drive&lt;/h3&gt;
Let's create a directory for our new tome. We will need this to mount filesystem.&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo &lt;span style="color: #200080; font-weight: bold;"&gt;mkdir&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine&lt;/pre&gt;
Lets unmount our tome (in case you did tested it exists with me).&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo umount &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1&lt;/pre&gt;
And add a proper &lt;b&gt;fstab&lt;/b&gt; entry to&amp;nbsp;auto-mount&amp;nbsp;this hard drive on boot. Open fstab:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo nano &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;fstab&lt;/pre&gt;
And add a line to the end of the file, indicating our Time Machine tome mounting preferences. Mine was:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;pre&gt;UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"AAAA-BBBB..."&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine hfsplus rw&lt;span style="color: #308080;"&gt;,&lt;/span&gt;force&lt;span style="color: #308080;"&gt;,&lt;/span&gt;exec&lt;span style="color: #308080;"&gt;,&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;auto&lt;/span&gt;&lt;span style="color: #308080;"&gt;,&lt;/span&gt;users &lt;span style="color: #008c00;"&gt;0&lt;/span&gt; &lt;span style="color: #008c00;"&gt;3&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
Where&amp;nbsp;&lt;b&gt;AAAA-BBBB...&lt;/b&gt; &amp;nbsp;is your devise UUID from that &lt;b&gt;blkid&lt;/b&gt; command&amp;nbsp;remember?&lt;br /&gt;
I used UUID to be sure it won't matter if I'll switch hard drives places in USB ports. But you may use &lt;b&gt;/dev/sdXX&lt;/b&gt;, where &lt;b&gt;XX&lt;/b&gt; is your device counting numbers in &lt;b&gt;/dev&lt;/b&gt;. Mine in this case was &lt;b&gt;/dev/sda1&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note: You can skip reboot.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Let's now do a reboot to make sure it all spins in automatic mode ;).&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo reboot

Broadcast message from root&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi &lt;span style="color: #308080;"&gt;(&lt;/span&gt;pts&lt;span style="color: #308080;"&gt;/&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt; &lt;span style="color: #308080;"&gt;(&lt;/span&gt;Wed Nov &lt;span style="color: #008c00;"&gt;21&lt;/span&gt; &lt;span style="color: #008c00;"&gt;19&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;13&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;&lt;span style="color: #008c00;"&gt;49&lt;/span&gt; &lt;span style="color: #008c00;"&gt;2012&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt;&lt;span style="color: #308080;"&gt;:&lt;/span&gt;
The system is going down &lt;span style="color: #200080; font-weight: bold;"&gt;for&lt;/span&gt; reboot NOW!&lt;/pre&gt;
After system boots up run &lt;b&gt;mount&lt;/b&gt;&amp;nbsp;command to make sure we are ok in &lt;b&gt;rw&lt;/b&gt; mode. Btw you may play with commands:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #595979;"&gt;# to unmount volume:&lt;/span&gt;
pi@raspberrypi &lt;span style="color: #308080;"&gt;~&lt;/span&gt; $ sudo umount &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1
&lt;span style="color: #595979;"&gt;# to mount again:&lt;/span&gt;
pi@raspberrypi &lt;span style="color: #308080;"&gt;~&lt;/span&gt; $ sudo mount UUID&lt;span style="color: #308080;"&gt;=&lt;/span&gt;&lt;span style="color: #1060b6;"&gt;"AAAA-BBBB..."&lt;/span&gt;&lt;/pre&gt;
While you will find your string. BTW you can read about how and why in /etc/fstab manual &lt;a href="https://help.ubuntu.com/community/Fstab"&gt;here...&lt;/a&gt;&amp;nbsp;Or google about it.&lt;br /&gt;
&lt;br /&gt;
Note: if your HFS+ tome does not mount and/or mounted read only. You should try to run fsck for hfsplus partition type manually.&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo fsck.hfsplus &lt;span style="color: #308080;"&gt;-&lt;/span&gt;f &lt;span style="color: #308080;"&gt;/&lt;/span&gt;dev&lt;span style="color: #308080;"&gt;/&lt;/span&gt;sda1&lt;/pre&gt;
Anyway we must now have an &lt;b&gt;rw&lt;/b&gt; mode &lt;b&gt;HFS+ &lt;/b&gt;volume mounted and ready for our Time Machine. So Lets move on...&lt;br /&gt;
&lt;br /&gt;
Checking your user permissions. As we will use user "&lt;b&gt;pi&lt;/b&gt;" farther along the article we must add him ability to manage Time Machine data. (In case you are not mounting empty drive). You should consider changing all the data owner to user "&lt;b&gt;pi&lt;/b&gt;" to make sure we will be abler to backup in future:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo chown &lt;span style="color: #308080;"&gt;-&lt;/span&gt;R pi &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine&lt;/pre&gt;
&lt;h3 style="text-align: left;"&gt;
4.&amp;nbsp;Install and configure Avahi and Netatalk demons&lt;/h3&gt;
&lt;div&gt;
First make sure you have the latest packages lists, running:&lt;/div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo apt&lt;span style="color: #308080;"&gt;-&lt;/span&gt;get update&lt;/pre&gt;
And updating what necessary.&lt;br /&gt;
&lt;br /&gt;
Now install all the required packages with db and encryption support in order Avahi and Netatalk demons to support for HFS+ filesystem:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo apt&lt;span style="color: #308080;"&gt;-&lt;/span&gt;get &lt;span style="color: #200080; font-weight: bold;"&gt;install&lt;/span&gt; avahi&lt;span style="color: #308080;"&gt;-&lt;/span&gt;daemon libavahi&lt;span style="color: #308080;"&gt;-&lt;/span&gt;client&lt;span style="color: #308080;"&gt;-&lt;/span&gt;dev libdb5.&lt;span style="color: #008c00;"&gt;3&lt;/span&gt;&lt;span style="color: #308080;"&gt;-&lt;/span&gt;dev db&lt;span style="color: #308080;"&gt;-&lt;/span&gt;util db5.&lt;span style="color: #008c00;"&gt;3&lt;/span&gt;&lt;span style="color: #308080;"&gt;-&lt;/span&gt;util libgcrypt11 libgcrypt11&lt;span style="color: #308080;"&gt;-&lt;/span&gt;dev&lt;/pre&gt;
After this is complete we will have almost everything required for our little&amp;nbsp;demon.&lt;br /&gt;
&lt;br /&gt;
Download and unpack 3.0.0 (latest, as for now is 3.0.1 but I had problems with it spinnig) Netatalk demon sources. For e.g. using command:&lt;b&gt; $ wget http://somesite.com/photos.zip&amp;nbsp;&lt;/b&gt;You may get Netatalk at&amp;nbsp;&lt;a href="http://netatalk.sourceforge.net/"&gt;SourceForge&lt;/a&gt;.&amp;nbsp;And unpack using e.g. &lt;a href="http://www.gnu.org/software/tar/manual/index.html"&gt;tar&lt;/a&gt;: &lt;b&gt;$&amp;nbsp;&lt;span class="kw2"&gt;tar&lt;/span&gt; &lt;span class="re5"&gt;-xvf&amp;nbsp;netatalk-3.0.0.tar.bz2&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class="re5"&gt;&lt;br /&gt;&lt;/span&gt;
After you are ready with unpacked netatalk&amp;nbsp;distribution&amp;nbsp;go ahead and make custom configuration of it. Enter directory of unarchived netatalk and execute command:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;pre&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;netatalk&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;3&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt; $ .&lt;span style="color: #308080;"&gt;/&lt;/span&gt;configure &lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #308080;"&gt;-&lt;/span&gt;with&lt;span style="color: #308080;"&gt;-&lt;/span&gt;init&lt;span style="color: #308080;"&gt;-&lt;/span&gt;style&lt;span style="color: #308080;"&gt;=&lt;/span&gt;debian &lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #308080;"&gt;-&lt;/span&gt;with&lt;span style="color: #308080;"&gt;-&lt;/span&gt;zeroconf&lt;/pre&gt;
&lt;/pre&gt;
It will do the proper configuration for our needs. After this is done run:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;netatalk&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;3&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt; $ make
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~&lt;span style="color: #308080;"&gt;/&lt;/span&gt;netatalk&lt;span style="color: #308080;"&gt;-&lt;/span&gt;&lt;span style="color: #008c00;"&gt;3&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt; $ sudo make &lt;span style="color: #200080; font-weight: bold;"&gt;install&lt;/span&gt;&lt;/pre&gt;
&lt;h3 style="text-align: left;"&gt;
5.&amp;nbsp;Configure Netatalk daemon to make it all serve as a Time Machine&lt;/h3&gt;
&lt;div&gt;
Now when you will have all this done go edit a configuration file of Netatalk. From version 3.0 it is located in /usr/local/etc and has Samba-like look. You can symlink this file to /etc/afp.conf if you wish...&amp;nbsp;&lt;/div&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo nano &lt;span style="color: #308080;"&gt;/&lt;/span&gt;usr&lt;span style="color: #308080;"&gt;/&lt;/span&gt;local&lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;afp.conf&lt;/pre&gt;
And insert this sample configuration. This config file works with latest edition ( now it is 10.8.2 ) of OS X Mountain Lion. So the config:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #595979;"&gt;;&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; Netatalk 3.x configuration file&lt;/span&gt;
&lt;span style="color: #595979;"&gt;;&lt;/span&gt;

&lt;span style="color: #308080;"&gt;[&lt;/span&gt;Global&lt;span style="color: #308080;"&gt;]&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; Global server settings&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; Name of your computer in apple devices network&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;hostname&lt;/span&gt; &lt;span style="color: #308080;"&gt;=&lt;/span&gt; TimeMachine Pi
&lt;span style="color: #595979;"&gt;; IP of your Pi&lt;/span&gt;
afp listen &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;192&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;168&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;140&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; logging config&lt;/span&gt;
log &lt;span style="color: #200080; font-weight: bold;"&gt;file&lt;/span&gt; &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;var&lt;span style="color: #308080;"&gt;/&lt;/span&gt;log&lt;span style="color: #308080;"&gt;/&lt;/span&gt;netatalk.log
log level &lt;span style="color: #308080;"&gt;=&lt;/span&gt; default&lt;span style="color: #308080;"&gt;:&lt;/span&gt;info

&lt;span style="color: #308080;"&gt;[&lt;/span&gt;Homes&lt;span style="color: #308080;"&gt;]&lt;/span&gt;
basedir regex &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;home
cnid scheme &lt;span style="color: #308080;"&gt;=&lt;/span&gt; dbd
&lt;span style="color: #595979;"&gt;; Display each user home directory in this format&lt;/span&gt;
home &lt;span style="color: #200080; font-weight: bold;"&gt;name&lt;/span&gt; &lt;span style="color: #308080;"&gt;=&lt;/span&gt; Home&lt;span style="color: #308080;"&gt;:&lt;/span&gt; $u
&lt;span style="color: #308080;"&gt;[&lt;/span&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;Time&lt;/span&gt; Machine&lt;span style="color: #308080;"&gt;]&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; Our Time Machine volume&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;path&lt;/span&gt; &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;mnt&lt;span style="color: #308080;"&gt;/&lt;/span&gt;TimeMachine
cnid scheme &lt;span style="color: #308080;"&gt;=&lt;/span&gt; dbd
&lt;span style="color: #200080; font-weight: bold;"&gt;file&lt;/span&gt; perm &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0660&lt;/span&gt;
directory perm &lt;span style="color: #308080;"&gt;=&lt;/span&gt; &lt;span style="color: #008c00;"&gt;0770&lt;/span&gt;
&lt;span style="color: #200080; font-weight: bold;"&gt;time&lt;/span&gt; machine &lt;span style="color: #308080;"&gt;=&lt;/span&gt; yes

&lt;span style="color: #595979;"&gt;; Example to add a new static share:&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; [My AFP Volume]&lt;/span&gt;
&lt;span style="color: #595979;"&gt;; path = /path/to/volume&lt;/span&gt;&lt;/pre&gt;
It is quite well commented so you will be able to copy-paste and edit ;).&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
6. Configuring AVAHI services&amp;nbsp;&lt;/h3&gt;
Now you would probably want to have a Time Capsule as a separate share in your network shares. &lt;b&gt;Note this step is optional. &lt;/b&gt;But if you plan to use your pi for more than 1 thing, like I do... I'd recommend to do it. Create a special afpd services configuration file by executing:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;pre&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo nano &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;avahi&lt;span style="color: #308080;"&gt;/&lt;/span&gt;services&lt;span style="color: #308080;"&gt;/&lt;/span&gt;timecapsule_afpd.service&lt;/pre&gt;
&lt;/pre&gt;
Then add this contents to file:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #007d45;"&gt;&amp;lt;?xml version="1.0" standalone='no'?&amp;gt;&lt;/span&gt;
&lt;span style="color: #007d45;"&gt;&amp;lt;!DOCTYPE service-group SYSTEM "avahi-service.dtd"&amp;gt;&lt;/span&gt;
&lt;span style="color: #007d45;"&gt;&amp;lt;service-group&amp;gt;&lt;/span&gt;
      &lt;span style="color: #007d45;"&gt;&amp;lt;name replace-wildcards="yes"&amp;gt;&lt;/span&gt;TimeCapsule %h&lt;span style="color: #007d45;"&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;
      &lt;span style="color: #007d45;"&gt;&amp;lt;service&amp;gt;&lt;/span&gt;
          &lt;span style="color: #007d45;"&gt;&amp;lt;type&amp;gt;&lt;/span&gt;_afpovertcp._tcp&lt;span style="color: #007d45;"&gt;&amp;lt;/type&amp;gt;&lt;/span&gt;
          &lt;span style="color: #007d45;"&gt;&amp;lt;port&amp;gt;&lt;/span&gt;&lt;span style="color: #008c00;"&gt;548&lt;/span&gt;&lt;span style="color: #007d45;"&gt;&amp;lt;/port&amp;gt;&lt;/span&gt;
      &lt;span style="color: #007d45;"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
      &lt;span style="color: #007d45;"&gt;&amp;lt;service&amp;gt;&lt;/span&gt;
          &lt;span style="color: #007d45;"&gt;&amp;lt;type&amp;gt;&lt;/span&gt;_device&lt;span style="color: #308080;"&gt;-&lt;/span&gt;info._tcp&lt;span style="color: #007d45;"&gt;&amp;lt;/type&amp;gt;&lt;/span&gt;
          &lt;span style="color: #007d45;"&gt;&amp;lt;port&amp;gt;&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;&lt;span style="color: #007d45;"&gt;&amp;lt;/port&amp;gt;&lt;/span&gt;
          &lt;span style="color: #007d45;"&gt;&amp;lt;txt-record&amp;gt;&lt;/span&gt;model&lt;span style="color: #308080;"&gt;=&lt;/span&gt;TimeCapsule&lt;span style="color: #007d45;"&gt;&amp;lt;/txt-record&amp;gt;&lt;/span&gt;
      &lt;span style="color: #007d45;"&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
&lt;span style="color: #007d45;"&gt;&amp;lt;/service-group&amp;gt;&lt;/span&gt;&lt;/pre&gt;
After this is configured for your desired settings. Go run your demons:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;init.d&lt;span style="color: #308080;"&gt;/&lt;/span&gt;netatalk &lt;span style="color: #200080; font-weight: bold;"&gt;start&lt;/span&gt;
pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ sudo &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;init.d&lt;span style="color: #308080;"&gt;/&lt;/span&gt;avahi&lt;span style="color: #308080;"&gt;-&lt;/span&gt;daemon &lt;span style="color: #200080; font-weight: bold;"&gt;start&lt;/span&gt;&lt;/pre&gt;
Avahi demon was installed from package. So you might need to actually run &lt;b&gt;restart&lt;/b&gt; instead of &lt;b&gt;start&lt;/b&gt; command. Now go check your Mac's Network Shares.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
7.&amp;nbsp;Put avahi and netatalk demons into autolaunch on system boot&lt;/h3&gt;
We have installed here an avahi demon from package. So it must be written to all system&amp;nbsp;run-levels&amp;nbsp;during&amp;nbsp;installation. Only thing here is compiled Netatalk 3.0 so you can make a proper trick here by putting it to run with default init.d command:&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;pre&gt;pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;~&lt;/span&gt; $ cd &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;init&lt;span style="color: #308080;"&gt;.&lt;/span&gt;d&lt;span style="color: #308080;"&gt;/&lt;/span&gt;
pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;~&lt;/span&gt; $ sudo update&lt;span style="color: #308080;"&gt;-&lt;/span&gt;rc&lt;span style="color: #308080;"&gt;.&lt;/span&gt;d netatalk defaults
update&lt;span style="color: #308080;"&gt;-&lt;/span&gt;rc&lt;span style="color: #308080;"&gt;.&lt;/span&gt;d&lt;span style="color: #406080;"&gt;:&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;using&lt;/span&gt; dependency based boot sequencing
update&lt;span style="color: #308080;"&gt;-&lt;/span&gt;rc&lt;span style="color: #308080;"&gt;.&lt;/span&gt;d&lt;span style="color: #406080;"&gt;:&lt;/span&gt; warning&lt;span style="color: #406080;"&gt;:&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;default&lt;/span&gt; stop runlevel arguments &lt;span style="color: #308080;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;0&lt;/span&gt; &lt;span style="color: #008c00;"&gt;1&lt;/span&gt; &lt;span style="color: #008c00;"&gt;6&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt; &lt;span style="color: #200080; font-weight: bold;"&gt;do&lt;/span&gt; not match netatalk Default&lt;span style="color: #308080;"&gt;-&lt;/span&gt;Stop values &lt;span style="color: #308080;"&gt;(&lt;/span&gt;&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;&lt;span style="color: #308080;"&gt;)&lt;/span&gt;
pi&lt;span style="background-color: #dd9999; background-position: initial initial; background-repeat: initial initial; color: white; font-style: italic; font-weight: bold;"&gt;@raspberrypi&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;init&lt;span style="color: #308080;"&gt;.&lt;/span&gt;d $&lt;/pre&gt;
&lt;/pre&gt;
You can read about system runlevels and why this command and not another in this article:&lt;br /&gt;
&lt;a href="http://www.debuntu.org/how-to-manage-services-with-update-rc.d"&gt;http://www.debuntu.org/how-to-manage-services-with-update-rc.d&lt;/a&gt; I find it nice simple and easy.&lt;br /&gt;
You can also read about Time Capsule theory and find answers to many "why?" questions here:&amp;nbsp;&lt;a href="http://buffalo.nas-central.org/wiki/Time_Machine_&amp;amp;_Time_Capsule_support_on_your_LinkStation"&gt;http://buffalo.nas-central.org/wiki/Time_Machine_&amp;amp;_Time_Capsule_support_on_your_LinkStation&lt;/a&gt;&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
Result:&lt;/h3&gt;
TADAM. The moment of truth. You can look into your Network Shares on a MAC. Select a virtual Time Capsule and hit &lt;b&gt;"Connect as..."&lt;/b&gt;&amp;nbsp;button. Login to your raspberry with user &lt;b&gt;pi &lt;/b&gt;and saving password.&amp;nbsp;Enter Time Machine directory... And Time Machine share will appear on a desktop (If it is configured to appear for newly mounted volumes...). You will experience something like this:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-r8Uwv7RkxQw/ULEHX-z17WI/AAAAAAAAFeQ/qVM7iYyKPwc/s1600/Screen+Shot+2012-11-24+at+7.42.06+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="361" src="http://3.bp.blogspot.com/-r8Uwv7RkxQw/ULEHX-z17WI/AAAAAAAAFeQ/qVM7iYyKPwc/s640/Screen+Shot+2012-11-24+at+7.42.06+PM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
After all of this is done. Go enter your Time Machine settings and add a new drive. Bckuping on a time capsule is some kind of different to&amp;nbsp;backing up&amp;nbsp;into external (e.g. USB) hard disk drives. Using external HDD as a Time Machine backup disk will store folder &lt;b&gt;Backups.backupdb&lt;/b&gt; into the root of your drive. But backup into time capsule (network backup) creates a volume like &lt;b&gt;leopard.sparsebundle&lt;/b&gt;, where this leopard is your MAC's name. And connects it as a file system image, storing this folder inside. So to make initial backup connecting through USB and then continue making backups is possible but irrelevant. Because you would have to mount this image and change permission of all files. Then move them into mounted virtual image under Pi or over network. So the advantages of this idea are controversial.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
It was looking like so for me:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-Ytty5I8-sE4/ULTmxO-1oOI/AAAAAAAAFek/QtlptNMJovk/s1600/Screen+Shot+2012-11-27+at+5.23.47+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="428" src="http://1.bp.blogspot.com/-Ytty5I8-sE4/ULTmxO-1oOI/AAAAAAAAFek/QtlptNMJovk/s640/Screen+Shot+2012-11-27+at+5.23.47+PM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
And my pi, serving like a Time Capsule and external HDD:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-ramisdoHF-M/ULTnzJtAgdI/AAAAAAAAFes/TI7kWzUhHBM/s1600/1111.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="394" src="http://2.bp.blogspot.com/-ramisdoHF-M/ULTnzJtAgdI/AAAAAAAAFes/TI7kWzUhHBM/s640/1111.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
Please comment your thoughts about all of this. Every comment is&amp;nbsp;appreciated. Thanks. And hope someone would benefit from those my findings.&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/pwnWN3uQYnI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/1941916590997192663/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/11/time-capsule-for-25.html#comment-form" title="72 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1941916590997192663?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1941916590997192663?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/pwnWN3uQYnI/time-capsule-for-25.html" title="Time Capsule for $25" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s72-c/Screen+Shot+2012-11-10+at+4.44.47+PM.png" height="72" width="72" /><thr:total>72</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.666856 25.167454499999998 50.82761 25.4833115</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/11/time-capsule-for-25.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEMR3c_eip7ImA9WhNQE0w.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-2830979814665182301</id><published>2012-11-19T10:44:00.002+02:00</published><updated>2012-11-19T10:44:46.942+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-19T10:44:46.942+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="dd" /><category scheme="http://www.blogger.com/atom/ns#" term="raspberry" /><category scheme="http://www.blogger.com/atom/ns#" term="configuration" /><category scheme="http://www.blogger.com/atom/ns#" term="etc" /><category scheme="http://www.blogger.com/atom/ns#" term="network" /><category scheme="http://www.blogger.com/atom/ns#" term="router" /><category scheme="http://www.blogger.com/atom/ns#" term="pi" /><category scheme="http://www.blogger.com/atom/ns#" term="user" /><category scheme="http://www.blogger.com/atom/ns#" term="interfaces" /><category scheme="http://www.blogger.com/atom/ns#" term="setup" /><category scheme="http://www.blogger.com/atom/ns#" term="clone" /><category scheme="http://www.blogger.com/atom/ns#" term="card" /><category scheme="http://www.blogger.com/atom/ns#" term="static" /><category scheme="http://www.blogger.com/atom/ns#" term="install" /><category scheme="http://www.blogger.com/atom/ns#" term="resolv.conf" /><category scheme="http://www.blogger.com/atom/ns#" term="simple" /><category scheme="http://www.blogger.com/atom/ns#" term="basic" /><category scheme="http://www.blogger.com/atom/ns#" term="config" /><category scheme="http://www.blogger.com/atom/ns#" term="flash" /><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi" /><title>Raspberry Pi first steps and basic network configuration on a Mac</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s1600/Screen+Shot+2012-11-10+at+4.44.47+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s200/Screen+Shot+2012-11-10+at+4.44.47+PM.png" width="169" /&gt;&lt;/a&gt;&lt;/div&gt;
Here are my first steps. And I hope you will find something&amp;nbsp;useful&amp;nbsp;here, while configuring your Pi...&lt;br /&gt;
First of all. Mine have been bought on ebay, from&amp;nbsp;resellers. And were delivered a while ago. Main purpose of this&amp;nbsp;purchase&amp;nbsp;war to attach a headless server to my router. I have 2 external HDD's and would like to have torrents, Time Mashine fro my macs and so on. So buying a handheld computer like this would be a bargain for me.&lt;br /&gt;
&lt;br /&gt;
As for built in&amp;nbsp;decisions&amp;nbsp;like some kinds of NAT devices and different routers with external HDD features... They are either cost a lot or lack some kinds of desired functionality. So the goal is to make some kind http/api&amp;nbsp;manageable&amp;nbsp;server in my local network with Time Mashine and file storage/backup. Just for fun. And to have only laptop on my work table.&lt;br /&gt;
&lt;br /&gt;
SO back to the Pi. If you are buying "device only" configuration, like I did. First of all you'll need some different kind of things many computer fans usually have for backup purposes, or just in case... Those are device with HDMI port or either a TV set with AV input, e.g. SCART or Video in port. A keyboard (USB, of&amp;nbsp;course) and SD card usually bigger then 2 Gigabytes.&lt;br /&gt;
&lt;br /&gt;
I had this all. So I've connected my PI and tried to flash a card, having problems doing it. I'll try to cover most of them here.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Install a system.&lt;/b&gt; Usually it is a simple "burning an SD card" with Raspbian Linux distribution. To do this you need to download it from:&amp;nbsp;&lt;a href="http://www.raspberrypi.org/downloads"&gt;HERE&lt;/a&gt;&amp;nbsp;and do actions from &lt;a href="http://elinux.org/RPi_Easy_SD_Card_Setup"&gt;official manual here&lt;/a&gt; with looking further note first.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem:&lt;/b&gt; "dd" does not work like intended, because volume is bisy.&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt; We need to unmount volume, using diskutil command with "force" flag for e.g.:&lt;br /&gt;
&lt;b&gt;sudo diskutil umount force /Volumes/my_flash_drive&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem:&lt;/b&gt; Doing "dd" command under mac environment did write the card, but took ages on my mac's config. So the...&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt; Is modified dd command call with manually specifying block size. This will speed up sd card write&amp;nbsp;tremendously.&lt;br /&gt;
&lt;b&gt;dd bs=1m if=~/Downloads/debian6-19-04-2012/debian6-19-04-2012.img of=/dev/rdisk1&lt;/b&gt;&lt;br /&gt;
Note "bs=1m" here. It helped my SD card burning not to hang out to infinite time.&lt;br /&gt;
&lt;br /&gt;
After SD card was written and you are good to go...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. Pi initial config.&lt;/b&gt;&amp;nbsp;Appears after first boot and looks like so:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/--gXfDx50jPM/UKnhW-WIgiI/AAAAAAAAFcQ/Iotea_zj-_g/s1600/Screen+Shot+2012-11-19+at+9.35.13+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="388" src="http://2.bp.blogspot.com/--gXfDx50jPM/UKnhW-WIgiI/AAAAAAAAFcQ/Iotea_zj-_g/s640/Screen+Shot+2012-11-19+at+9.35.13+AM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
You can run it afterwards using command &lt;b&gt;"sudo raspi-config"&lt;/b&gt;. Just in case you would missed something hitting &lt;b&gt;Esc &lt;/b&gt;or similar. It will be available via ssh in future&amp;nbsp;also.&lt;br /&gt;
&lt;br /&gt;
Tools you will use here are similar to bios config on a PC. So to get started:&lt;br /&gt;
&lt;br /&gt;
Here you need to &lt;b&gt;expand rootfs&lt;/b&gt;&amp;nbsp;(to use entire SD card space) I doubt you have original Pi Raspbian card. But you may skip this step in case you do. This will be executed on next start. So feel free to do it first thing.&lt;br /&gt;
&lt;br /&gt;
Next important option is &lt;b&gt;change pass &lt;/b&gt;and you need it&amp;nbsp;no-mater&amp;nbsp;what. It will change your default user's with username &lt;b&gt;pi&lt;/b&gt;&amp;nbsp;password. It is similar to user with root permissions... So be sure to do it. Note password symbols are not displayed during entry.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;change timezone&lt;/b&gt; goes next. If you do not leave in &lt;b&gt;other&lt;/b&gt; timezone, like I do, change it. ;) Note pi does not have an&amp;nbsp;internal "bios"&amp;nbsp;clock so you would need to do it. Because time is used from internet atomic clocks...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;memory split&lt;/b&gt; is also important option that help you to manage precious pi's RAM. I've used 16 because I will not need GUI and will run "headless", using it via ssh/network services. To use GUI consider 32+ Mb or RAM for video memory.&amp;nbsp;But note RAM is really in lack for most modern services. and you may need every Kb of it in future.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ssh&lt;/b&gt; is our main goal. To access it/configure it in future. Hit it to enable ssh connections.&lt;br /&gt;
&lt;br /&gt;
and you can run &lt;b&gt;update &lt;/b&gt;if you have already connected network somehow :).&lt;br /&gt;
&lt;br /&gt;
That's it with basic config for our needs. Here goes...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. Static network configuration.&lt;/b&gt;&lt;br /&gt;
I think this is the most important part. Because I have googled a lot to find a proper solution for my needs.&lt;br /&gt;
&lt;br /&gt;
Pi is connected via dhcp IP address, usually given randomly by your router. And you need to make it static to know you will always have pi under certain network address.&lt;br /&gt;
&lt;br /&gt;
You may know your Pi's ip address by entring &lt;b&gt;route&lt;/b&gt;&amp;nbsp;command into prompt. Yo will see something like this.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;raspberrypi ~ $ &lt;span style="color: #200080; font-weight: bold;"&gt;route&lt;/span&gt;
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    &lt;span style="color: #200080; font-weight: bold;"&gt;Use&lt;/span&gt; Iface
default         &lt;span style="color: #008c00;"&gt;192&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;168&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;     &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;         UG    &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;      &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;        &lt;span style="color: #008c00;"&gt;0&lt;/span&gt; eth0
&lt;span style="color: #008c00;"&gt;192&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;168&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;     *               &lt;span style="color: #008c00;"&gt;255&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;255&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;255&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;0&lt;/span&gt;   U     &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;      &lt;span style="color: #008c00;"&gt;0&lt;/span&gt;        &lt;span style="color: #008c00;"&gt;0&lt;/span&gt; eth0&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Here you can see your network is in range 192.168.1.x. Biut if you are configuring your Pi without actual network config, like I did, you will need to do something like this:&lt;br /&gt;
&lt;br /&gt;
You need to know it from your router config. And you can simply connect it via network, if you did it properly in past. Or either connect, like you did for initial router config. You need something like this, saying about your LAN network address. I have a wired mix of different network&amp;nbsp;decisions&amp;nbsp;in my router. So note your typical network router address here:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-z07eIaNpb34/UKnoEoXyY7I/AAAAAAAAFck/95js5S7mFS4/s1600/Screen+Shot+2012-11-19+at+10.03.24+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="298" src="http://3.bp.blogspot.com/-z07eIaNpb34/UKnoEoXyY7I/AAAAAAAAFck/95js5S7mFS4/s640/Screen+Shot+2012-11-19+at+10.03.24+AM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
Here you can know your router's DHCP address. And usually you can do it by&amp;nbsp;examining&amp;nbsp;your router's user manual.&lt;br /&gt;
Anyway this tells me that I have a wire (LAN) IP network with adress range 192.168.1.&lt;b&gt;x&lt;/b&gt; where &lt;b&gt;x&lt;/b&gt; is between 1 and 254. Your DHCP in router may work in another way and have different interface. So you may have other IP range set. E.g. Mine had a &lt;b&gt;100-199&lt;/b&gt; range by default:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-mLwke8KO4K4/UKnpAtvqoWI/AAAAAAAAFcs/EyCZiZyE-OQ/s1600/Screen+Shot+2012-11-19+at+10.08.12+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="294" src="http://2.bp.blogspot.com/-mLwke8KO4K4/UKnpAtvqoWI/AAAAAAAAFcs/EyCZiZyE-OQ/s640/Screen+Shot+2012-11-19+at+10.08.12+AM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
I've chosen a 192.168.1.140 IP &amp;nbsp;for my PI, because I would not have 40 devices in my network and would not have any possible IP conflicts this way.&lt;br /&gt;
&lt;br /&gt;
This are data required for our Pi network config. We need to manually change this in our Pi's config files.&lt;br /&gt;
&lt;br /&gt;
Try to do this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;&lt;span style="color: #200080; font-weight: bold;"&gt;cd&lt;/span&gt; &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;network
sudo nano interfaces&lt;/pre&gt;
&lt;br /&gt;
This will start default Pi's text editor, called "nano", pointing to networks configuration file. Here is how it might look like:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-TjnrOrhEeEE/UKnqkG_cnQI/AAAAAAAAFc0/KfPfitb1-C8/s1600/Screen+Shot+2012-11-19+at+10.14.26+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="388" src="http://1.bp.blogspot.com/-TjnrOrhEeEE/UKnqkG_cnQI/AAAAAAAAFc0/KfPfitb1-C8/s640/Screen+Shot+2012-11-19+at+10.14.26+AM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
You can notice nice hotkeys here in the bottom. So I think you will be pleased with this user interface. Let's replace the line&amp;nbsp;&lt;span style="background-color: #f6f8ff; color: #000020;"&gt;iface eth0 inet dhcp&lt;/span&gt;&amp;nbsp;with lines.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;iface eth0 inet &lt;span style="color: #200080; font-weight: bold;"&gt;static&lt;/span&gt;
address &lt;span style="color: green;"&gt;192.168&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;1.140&lt;/span&gt;
netmask &lt;span style="color: green;"&gt;255.255&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;255.0&lt;/span&gt;
gateway &lt;span style="color: green;"&gt;192.168&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;1.1&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
This will create a static address for our Pi.&amp;nbsp;Now to make sure we have a proper DNS. Go to editing /etc/resolv.conf. E.g. type:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;sudo nano &lt;span style="color: #308080;"&gt;/&lt;/span&gt;etc&lt;span style="color: #308080;"&gt;/&lt;/span&gt;resolv.conf&lt;/pre&gt;
&lt;br /&gt;
Mine had a a line:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;nameserver &lt;span style="color: green;"&gt;8.8&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;8.8&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Pointing to google's DNS. And I've left it, adding my router as a first DNS. So my resolv.conf became looking like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;nameserver &lt;span style="color: green;"&gt;192.168&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;1.1&lt;/span&gt;
nameserver &lt;span style="color: green;"&gt;8.8&lt;/span&gt;&lt;span style="color: #308080;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;8.8&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
And that's it. After doing this you would have to restart network interfaces. Or better do &lt;b&gt;"sudo reboot"&lt;/b&gt; to make sure everything is configured. At this point you are OK to go running headless already. You can now do ssh connections to static ip at your pi.&lt;br /&gt;
&lt;br /&gt;
So to use it you would need only to type in your terminal:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #f6f8ff; color: #000020;"&gt;ssh pi&lt;span style="color: #308080;"&gt;@&lt;/span&gt;&lt;span style="color: #008c00;"&gt;192&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;168&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;1&lt;/span&gt;.&lt;span style="color: #008c00;"&gt;140&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
This will connect you to your pi. And you are ready to go ahead.&lt;br /&gt;
you may see something like this:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-dIfKmY4IGHc/UKntbvTPCtI/AAAAAAAAFdI/RJglRZYC3IU/s1600/Screen+Shot+2012-11-19+at+10.26.11+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="388" src="http://1.bp.blogspot.com/-dIfKmY4IGHc/UKntbvTPCtI/AAAAAAAAFdI/RJglRZYC3IU/s640/Screen+Shot+2012-11-19+at+10.26.11+AM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And to finish here is how my Pi looks like in a "printable case" The Punnet from user "E". Thanks to him.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-C0Qvkdn95Vs/UKnxB-Ik4HI/AAAAAAAAFdc/1_ea38zEHEw/s1600/%D1%84%D0%BE%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="478" src="http://2.bp.blogspot.com/-C0Qvkdn95Vs/UKnxB-Ik4HI/AAAAAAAAFdc/1_ea38zEHEw/s640/%D1%84%D0%BE%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/u9zjy2dZgi4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/2830979814665182301/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/11/raspberry-pi-first-steps-and-basic.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2830979814665182301?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2830979814665182301?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/u9zjy2dZgi4/raspberry-pi-first-steps-and-basic.html" title="Raspberry Pi first steps and basic network configuration on a Mac" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-oMwxo82QSgw/UKkNPpziFfI/AAAAAAAAFb8/gOeDYk1bSdE/s72-c/Screen+Shot+2012-11-10+at+4.44.47+PM.png" height="72" width="72" /><thr:total>1</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.666856 25.167454499999998 50.82761 25.4833115</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/11/raspberry-pi-first-steps-and-basic.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEIDRXg4eyp7ImA9WhNSGUg.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-8656597885297242546</id><published>2012-11-03T17:21:00.000+02:00</published><updated>2012-11-03T17:29:34.633+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-03T17:29:34.633+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="data" /><category scheme="http://www.blogger.com/atom/ns#" term="free" /><category scheme="http://www.blogger.com/atom/ns#" term="space" /><category scheme="http://www.blogger.com/atom/ns#" term="link" /><category scheme="http://www.blogger.com/atom/ns#" term="time mashine" /><category scheme="http://www.blogger.com/atom/ns#" term="disable local backups" /><category scheme="http://www.blogger.com/atom/ns#" term="hdd" /><category scheme="http://www.blogger.com/atom/ns#" term="second drive" /><category scheme="http://www.blogger.com/atom/ns#" term="OS X" /><category scheme="http://www.blogger.com/atom/ns#" term="restore" /><category scheme="http://www.blogger.com/atom/ns#" term="migrate" /><category scheme="http://www.blogger.com/atom/ns#" term="migration" /><category scheme="http://www.blogger.com/atom/ns#" term="iTunes" /><category scheme="http://www.blogger.com/atom/ns#" term="ssd" /><category scheme="http://www.blogger.com/atom/ns#" term="compact" /><category scheme="http://www.blogger.com/atom/ns#" term="caddy" /><category scheme="http://www.blogger.com/atom/ns#" term="move" /><category scheme="http://www.blogger.com/atom/ns#" term="drive" /><category scheme="http://www.blogger.com/atom/ns#" term="iPhoto" /><category scheme="http://www.blogger.com/atom/ns#" term="Lion" /><title>Migration from HDD to SSD with Mac OS X Lion</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-cebRh-gPnYk/UJU4UdqKBrI/AAAAAAAAFbo/o6DlSKgHW6k/s1600/4811.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="83" src="http://1.bp.blogspot.com/-cebRh-gPnYk/UJU4UdqKBrI/AAAAAAAAFbo/o6DlSKgHW6k/s200/4811.gif" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
Today I'll try to cover my migration experience. I have bought myself an &lt;a href="http://www.amazon.com/gp/product/B007R1FH3K/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B007R1FH3K&amp;amp;linkCode=as2&amp;amp;tag=webprogrammer-20"&gt;OCZ Technology 128GB Vertex 4 SSD&lt;/a&gt;&lt;img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=webprogrammer-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B007R1FH3K" style="border: none !important; margin: 0px !important;" width="1" /&gt;
 from Amazon. And I also have an external 1 Tb HDD. I'm using it for migration purposes as a backup Time Mashine. So to migrate yourself without reinstalling operating system and so on you need:&lt;br /&gt;
&lt;br /&gt;
1. Compact your data. Usually HDD's, installed in Mac's, are much bigger then SSD's you buying. And to tell you the truth, you&amp;nbsp;probably&amp;nbsp;do not need a 512 Gigabytes SSD at all. Most of data are accessed rarely and do not require speedy storage. So COMPACT them. Move to an external HDD and/or delete. Time to cleanup one word. There are also several places that can be easily deleted without much troubles. They are iTunes backup caches for your iOS devices, like iPhones and iPads.&lt;br /&gt;
they are usually sotred on your user library path.&lt;br /&gt;
You can delete them without sorry from either:&lt;br /&gt;
&lt;b&gt;~/Library/Application Support/MobileSync/Backup&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
folder or in your iTunes =&amp;gt; Preferences =&amp;gt; Devices section, hitting delete on each backup.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-tXDqjzDjVcw/UJUmzYB8IcI/AAAAAAAAFaI/AP0QOniAlx4/s1600/Screen+Shot+2012-11-03+at+4.13.29+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="175" src="http://4.bp.blogspot.com/-tXDqjzDjVcw/UJUmzYB8IcI/AAAAAAAAFaI/AP0QOniAlx4/s200/Screen+Shot+2012-11-03+at+4.13.29+PM.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
They will be created from scratch on next sync. So no worries about them. Your data are safe on your mobile devices. If you do not screw things up on next sync (:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Besides this you have ability to link files. For e.g. I have an iTunes library of around 100 Gigs of songs, books and etc. So storing it by default path is bad idea. My SSD only has 128 Gigabytes. Anyway I'll tell what to do with this later on. For now I'll just say you can move iTunes Libraries and relink them. And you can move iPhoto library. I have around 100 Gigs of photos too... So those 2 are moved to external HDD. Leaving me 200 gigabytes of data. After deleting iTunes backups I've fried around 60+ gigs. I have had several iPhones and their backups also were stored there. So the list was big.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Anyway. The file system started to look like this:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-yaO973yjhOw/UJUo54qqL-I/AAAAAAAAFaQ/U0QDY_4Qt1o/s1600/Screen+Shot+2012-10-30+at+12.26.00+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="301" src="http://2.bp.blogspot.com/-yaO973yjhOw/UJUo54qqL-I/AAAAAAAAFaQ/U0QDY_4Qt1o/s400/Screen+Shot+2012-10-30+at+12.26.00+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
But I've fried this space, and made a backup. Why the hell I have no free space. And my Mac says I have only 70+ gigs of space used. The catch is in &lt;b&gt;.MobileBackups&lt;/b&gt; folder. Mac stores your Time Mashine backups to local hard drive.&amp;nbsp;Backing up&amp;nbsp;data locally. What a mess :). You can disable it by hitting terminal command:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b&gt;$ sudo tmutil disablelocal&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
this will disable local Time Mashine backups. TADAAM. We really&amp;nbsp;have&amp;nbsp;a hard drive with around 78 gigs of space used for system and files.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-6zGVVO6BrjU/UJUqORanDTI/AAAAAAAAFaY/yPWoI8wrycg/s1600/Screen+Shot+2012-10-30+at+1.13.49+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="176" src="http://3.bp.blogspot.com/-6zGVVO6BrjU/UJUqORanDTI/AAAAAAAAFaY/yPWoI8wrycg/s320/Screen+Shot+2012-10-30+at+1.13.49+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Now make a Time Mashine backup to external HDD, or second hdd, that will not be formatted and can be accessed during setup. Math is simple. Last backup must be smaller then your SSD capacity. 78 is quite ok for me.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-7SjukH254og/UJUrWgSTBOI/AAAAAAAAFag/oOE7dORmeA4/s1600/Screen+Shot+2012-11-03+at+4.33.25+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-7SjukH254og/UJUrWgSTBOI/AAAAAAAAFag/oOE7dORmeA4/s1600/Screen+Shot+2012-11-03+at+4.33.25+PM.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
In case you need to fit something on your HDD and have all the space used by Time Mashine backups, like I did, you can delete old Time&amp;nbsp;Mashine&amp;nbsp;backups in manual mode. Simply go to folder on your Time Mashine drive, called &lt;b&gt;Backups.backupd =&amp;gt; YourUserNameHere.&lt;/b&gt;&amp;nbsp;You will see a set of date stamped folders. Those are Time Mashine backup dates.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-XKn_cFoymxU/UJUsAPmcQXI/AAAAAAAAFao/_ci0Hni0sg4/s1600/Screen+Shot+2012-10-29+at+5.57.01+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="348" src="http://1.bp.blogspot.com/-XKn_cFoymxU/UJUsAPmcQXI/AAAAAAAAFao/_ci0Hni0sg4/s640/Screen+Shot+2012-10-29+at+5.57.01+PM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
You can free them up by deleting each folder and cleaning the trash. Note it will come to cleaning Trash with -&amp;nbsp;amount&amp;nbsp;of objects, e.g.: "deleting file -123". Don't bother with that and simply wait for cleanup.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Now that we have a most recent backup in Time Mashine of all our system HDD. We can proceed. Power of your Mac/Macbook and insert a SSD drive, if you have not done so before.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
I have used an Second SSD/HDD drive Caddy that is around 10$ at eBay.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Looks&amp;nbsp;something&amp;nbsp;like this:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-VHP3pmJ4PyM/UJUwa0XRZ7I/AAAAAAAAFa8/vxrAAUoN9dE/s1600/111.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/-VHP3pmJ4PyM/UJUwa0XRZ7I/AAAAAAAAFa8/vxrAAUoN9dE/s320/111.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
I've plugged my HDD there. And SSD came in place of HDD. But it's a metter of taste and you can do as you wish here.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Now time to boot. Boot, holding &lt;b&gt;"Option"&lt;/b&gt; key. You will see the menu with OS boot&amp;nbsp;choice, Looking something like that:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-pi31Q7Nx8Cw/UJUy2A7X-vI/AAAAAAAAFbE/rhIAM50Y3m4/s1600/Screen+Shot+2012-11-03+at+5.05.35+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="273" src="http://4.bp.blogspot.com/-pi31Q7Nx8Cw/UJUy2A7X-vI/AAAAAAAAFbE/rhIAM50Y3m4/s320/Screen+Shot+2012-11-03+at+5.05.35+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Choose Recovery HD. This will be mush simpler/quicker then making any external boots. But you may have to do it in case you do not have this option here. Anyway booting this option will lead you to a screen with recover&amp;nbsp;options.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-VfNZkzK_BEw/UJUziYC8sCI/AAAAAAAAFbM/cX4VV6EtL3I/s1600/Screen+Shot+2012-11-03+at+5.08.26+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="243" src="http://3.bp.blogspot.com/-VfNZkzK_BEw/UJUziYC8sCI/AAAAAAAAFbM/cX4VV6EtL3I/s320/Screen+Shot+2012-11-03+at+5.08.26+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Choose Restore From Time Mashine Backup. Will lead you to the drive with your Time Mashine selection, in case you have several.&amp;nbsp;Afterwards&amp;nbsp;select your LATEST! backup. And choose where to restore to. Be&amp;nbsp;careful&amp;nbsp;to choose your SSD. And hit Fire. :)&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
You will wait several minutes, depending on your Time Mashine drive speed with this screen:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-bFHl6LwFkzk/UJU0TLt0vNI/AAAAAAAAFbU/-5mwoeqVMVQ/s1600/Screen+Shot+2012-11-03+at+5.03.57+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="260" src="http://3.bp.blogspot.com/-bFHl6LwFkzk/UJU0TLt0vNI/AAAAAAAAFbU/-5mwoeqVMVQ/s400/Screen+Shot+2012-11-03+at+5.03.57+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
After load you will have fully restored system with all your data on a SSD.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Now be sure you have boot from an SSD ( It is usually hard to make a mush here because of boot speed :D ). But make sure you are on SSD now and go ahead to diskutil and format your HDD. You will not need it anymore. TADAM. You're done.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Thanks for reading this far and comments with your success are welcome, as long as&amp;nbsp;critics apriciated&amp;nbsp;;).&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/cmFANqrBIgg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/8656597885297242546/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/11/migration-from-hdd-to-ssd-with-mac-os-x.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/8656597885297242546?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/8656597885297242546?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/cmFANqrBIgg/migration-from-hdd-to-ssd-with-mac-os-x.html" title="Migration from HDD to SSD with Mac OS X Lion" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-cebRh-gPnYk/UJU4UdqKBrI/AAAAAAAAFbo/o6DlSKgHW6k/s72-c/4811.gif" height="72" width="72" /><thr:total>4</thr:total><georss:featurename>Voli Ave, 2, Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>-3.6077584999999956 -55.533992 90.0 106.184758</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/11/migration-from-hdd-to-ssd-with-mac-os-x.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMNRng8fCp7ImA9WhJbFUo.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-3864529412475463447</id><published>2012-09-25T14:53:00.002+03:00</published><updated>2012-09-25T15:34:57.674+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-25T15:34:57.674+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="blog" /><category scheme="http://www.blogger.com/atom/ns#" term="package" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="django-log-file-viewer" /><category scheme="http://www.blogger.com/atom/ns#" term="regex" /><category scheme="http://www.blogger.com/atom/ns#" term="parse" /><category scheme="http://www.blogger.com/atom/ns#" term="regexp" /><category scheme="http://www.blogger.com/atom/ns#" term="install" /><category scheme="http://www.blogger.com/atom/ns#" term="readme" /><category scheme="http://www.blogger.com/atom/ns#" term="log" /><category scheme="http://www.blogger.com/atom/ns#" term="pip" /><category scheme="http://www.blogger.com/atom/ns#" term="file" /><category scheme="http://www.blogger.com/atom/ns#" term="pypi" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="docs" /><category scheme="http://www.blogger.com/atom/ns#" term="re" /><title>Django Log Files Viewer documents</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;h2 style="text-align: left;"&gt;
Django Log File Viewer.&lt;/h2&gt;
&lt;div&gt;
This is a PYPI package &lt;a href="http://pypi.python.org/pypi/django-log-file-viewer/0.2"&gt;django-log-file-viewer&lt;/a&gt;&amp;nbsp;documents.&lt;br /&gt;
Github repo:&amp;nbsp;&lt;a href="https://github.com/garmoncheg/django-log-file-viewer/"&gt;django-log-file-viewer@garmoncheg.github.com&lt;/a&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
Usage:&lt;/h3&gt;
&lt;div style="text-align: left;"&gt;
Useful to add log files view functionality to your Django admin web site.&lt;br /&gt;
Instead of using database log files storage, it gives you ability to store/view log files through GUI.&lt;br /&gt;
It requires a directory with Django log files to function. E.g. directory structure:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;$ project_dir&lt;span style="color: #808030;"&gt;/&lt;/span&gt;logs&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
       applog&lt;span style="color: #808030;"&gt;.&lt;/span&gt;log
       applog&lt;span style="color: #808030;"&gt;.&lt;/span&gt;log&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #778c77;"&gt;2012&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #778c77;"&gt;09&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #778c77;"&gt;22&lt;/span&gt;
       &lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;
       errors&lt;span style="color: #808030;"&gt;.&lt;/span&gt;log
       applog&lt;span style="color: #808030;"&gt;.&lt;/span&gt;log&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #778c77;"&gt;2012&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #778c77;"&gt;09&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #778c77;"&gt;22&lt;/span&gt;
       &lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
Screenshots:&lt;/h3&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-skQAp3OowPw/UGGa_OA38dI/AAAAAAAAFZo/X12rQv-3bFY/s1600/dlfv1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="105" src="http://2.bp.blogspot.com/-skQAp3OowPw/UGGa_OA38dI/AAAAAAAAFZo/X12rQv-3bFY/s400/dlfv1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-hbxBgCgU-pg/UGGbCQju5DI/AAAAAAAAFZw/rIyPSrUrgGc/s1600/dlfv2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="73" src="http://3.bp.blogspot.com/-hbxBgCgU-pg/UGGbCQju5DI/AAAAAAAAFZw/rIyPSrUrgGc/s400/dlfv2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style="text-align: left;"&gt;
To parse/display these log files you need:&lt;/h2&gt;
&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
1. Install an app and add it to your settings.py INSTALLED_APPS section:&lt;/h3&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #b96969;"&gt;# settings.py&lt;/span&gt;
INSTALLED_APPS &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# ...&lt;/span&gt;
    &lt;span style="color: #cc5555;"&gt;'django-log-file-viewer'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# ...&lt;/span&gt;
&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
2. Set UP 2 django variables in settings.py:&lt;/h3&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #b96969;"&gt;# settings.py:&lt;/span&gt;
LOG_FILES_DIR &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'/path/to/your/log/directory'&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# Relative or static path string of your log files directory.&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# I recommend using more pythonic way of defining tis with os module. E.g. :&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# settings.py:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;#&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# LOG_FILES_DIR = os.path.join(APP_PATH, 'testdata', 'log')&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# &lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# where APP_PATH is your app's/project's path.&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;LOG_FILES_RE &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'(?P&amp;lt;date&amp;gt;\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s\[(?P&amp;lt;type&amp;gt;[A-Z]+)\]\s(?P&amp;lt;message&amp;gt;.+)'&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# Is a regex to parse your log file against. It completely depends of your Django logging settings.&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# And table column names (in a parsed logfile) depend from group names you provide in the regexp.&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# E.g. for Django logging server to parse with this regexp you need to have log, as in example&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# django_log_file_viewer/testdata/testing.log file.&lt;/span&gt;

    &lt;span style="color: #b96969;"&gt;# to produce this log I've added this formatter to my website.&lt;/span&gt;
    
    &lt;span style="color: #b96969;"&gt;#'formatters': {&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;#    'verbose': {&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;#        'format': '%(asctime)s [%(levelname)s] %(message)s'&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;#    },&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;#},&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
3. And add urls to your main urls section:&lt;/h3&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #b96969;"&gt;# urls.py&lt;/span&gt;
urlpatterns &lt;span style="color: #808030;"&gt;=&lt;/span&gt; patterns&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;

    &lt;span style="color: #b96969;"&gt;# Include this before admin to enable app admin url overrides&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# Note url must be the same as admin&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# This is required step&lt;/span&gt;
    url&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r'^admin/'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; include&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'django-log-file-viewer.admin_urls'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    url&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r'^admin/'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; include&lt;span style="color: #808030;"&gt;(&lt;/span&gt;admin&lt;span style="color: #808030;"&gt;.&lt;/span&gt;site&lt;span style="color: #808030;"&gt;.&lt;/span&gt;urls&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;

    &lt;span style="color: #b96969;"&gt;# To view with custom views:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# Optional step&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# Will ad urls like www.example.com/logfiles/&lt;/span&gt;
    url&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r''&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; include&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'django-log-file-viewer.urls'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
TODO's:&lt;/h3&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Add pagination to both log files list and log file content&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="text-align: left;"&gt;
Reference:&lt;/h3&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Info on how to add/config logging for your Django based website here: &lt;a href="https://docs.djangoproject.com/en/dev/topics/logging/"&gt;https://docs.djangoproject.com/en/dev/topics/logging/&lt;/a&gt; (Official Django documentation)&lt;/li&gt;
&lt;li&gt;Parsing/testing Regexp is useful with: &lt;a href="http://gskinner.com/RegExr/"&gt;http://gskinner.com/RegExr/&lt;/a&gt; (real time regexp testing)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/co2TcBi49eg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/3864529412475463447/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/09/django-log-files-viewer-documents.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/3864529412475463447?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/3864529412475463447?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/co2TcBi49eg/django-log-files-viewer-documents.html" title="Django Log Files Viewer documents" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-skQAp3OowPw/UGGa_OA38dI/AAAAAAAAFZo/X12rQv-3bFY/s72-c/dlfv1.png" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Voli Ave, 2, Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>45.103474500000004 15.217960999999999 56.3909915 35.432805</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/09/django-log-files-viewer-documents.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4DQnk-eip7ImA9WhJbEEo.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-239610826370117935</id><published>2012-09-19T21:22:00.002+03:00</published><updated>2012-09-19T21:22:53.752+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-19T21:22:53.752+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="files" /><category scheme="http://www.blogger.com/atom/ns#" term="tar" /><category scheme="http://www.blogger.com/atom/ns#" term="put" /><category scheme="http://www.blogger.com/atom/ns#" term="ssh" /><category scheme="http://www.blogger.com/atom/ns#" term="remote" /><category scheme="http://www.blogger.com/atom/ns#" term="transfer" /><category scheme="http://www.blogger.com/atom/ns#" term="download" /><category scheme="http://www.blogger.com/atom/ns#" term="archive" /><category scheme="http://www.blogger.com/atom/ns#" term="gzip" /><category scheme="http://www.blogger.com/atom/ns#" term="directory" /><category scheme="http://www.blogger.com/atom/ns#" term="file" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="Unix" /><category scheme="http://www.blogger.com/atom/ns#" term="compact" /><category scheme="http://www.blogger.com/atom/ns#" term="scp" /><category scheme="http://www.blogger.com/atom/ns#" term="mac" /><category scheme="http://www.blogger.com/atom/ns#" term="recursively" /><title>SSH Unix/Lunux Recipes for daily usage.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-EMOUjVNF2kc/UFoNDEvTIgI/AAAAAAAAFZU/d8--9TPKPeU/s1600/111.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/-EMOUjVNF2kc/UFoNDEvTIgI/AAAAAAAAFZU/d8--9TPKPeU/s200/111.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
I've decided to create a post with several recipes for commands I need to use daily. I use them from a Mac OS X Lion default console, except for some mac ports installed... Remote is special linux distribution.&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
How do I Compress a Whole Linux or UNIX Directory?&amp;nbsp;&lt;/h3&gt;
&lt;div&gt;
You need to use tar command as follows (syntax of tar command):&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;tar -zcvf archive-name.tar.gz directory-name&lt;/strong&gt;&lt;br /&gt; Where,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;-z: Compress archive using gzip program&lt;/li&gt;
&lt;li&gt;-c: Create archive&lt;/li&gt;
&lt;li&gt;-v: Verbose i.e display progress while creating archive&lt;/li&gt;
&lt;li&gt;-f: Archive File name&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
For example, you have directory called /home/garmoncheg/data and you would 
like to compress this directory then you can type tar command as 
follows:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;$ tar &lt;span style="color: #808030;"&gt;-&lt;/span&gt;zcvf data&lt;span style="color: #808030;"&gt;.&lt;/span&gt;tar&lt;span style="color: #808030;"&gt;.&lt;/span&gt;gz &lt;span style="color: #808030;"&gt;/&lt;/span&gt;home&lt;span style="color: #808030;"&gt;/&lt;/span&gt;garmoncheg&lt;span style="color: #808030;"&gt;/&lt;/span&gt;data&lt;span style="color: #40015a;"&gt;/&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Above command will create an archive file called data.tar.gz 
in current directory. If you wish to restore your archive then you need 
to use following command (it will extract all files in current 
directory):&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;$ tar &lt;span style="color: #808030;"&gt;-&lt;/span&gt;zxvf data&lt;span style="color: #808030;"&gt;.&lt;/span&gt;tar&lt;span style="color: #808030;"&gt;.&lt;/span&gt;gz&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Where,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;-x: Extract files&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style="text-align: left;"&gt;
Put or Retrieve a file from/to remote directory via SSH&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
For all those operations you need to use &lt;b&gt;scp &lt;/b&gt;command. It is like a &lt;b&gt;cp &lt;/b&gt;command under local unix/linux console. Except it does remote transfers.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So to put one file:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;scp file&lt;span style="color: #808030;"&gt;.&lt;/span&gt;dat garmoncheg&lt;span style="color: #808030;"&gt;.&lt;/span&gt;google&lt;span style="color: #808030;"&gt;.&lt;/span&gt;com&lt;span style="color: purple;"&gt;:&lt;/span&gt;NewData&lt;span style="color: #808030;"&gt;.&lt;/span&gt;txt&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
copy file "file.dat'' from your current computer/directory
 to your home directory on garmoncheg.google.com,&amp;nbsp;naming the copy on remote server "NewData.txt''. &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;scp file&lt;span style="color: #808030;"&gt;.&lt;/span&gt;dat garmoncheg&lt;span style="color: #808030;"&gt;.&lt;/span&gt;google&lt;span style="color: #808030;"&gt;.&lt;/span&gt;com&lt;span style="color: purple;"&gt;:&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
is the same thing, except file will be named like original at local&amp;nbsp;computer HD.&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;scp file&lt;span style="color: #808030;"&gt;.&lt;/span&gt;dat garmoncheg&lt;span style="color: #808030;"&gt;.&lt;/span&gt;google&lt;span style="color: #808030;"&gt;.&lt;/span&gt;com&lt;span style="color: purple;"&gt;:&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;home&lt;span style="color: #808030;"&gt;/&lt;/span&gt;garmoncheg&lt;span style="color: #808030;"&gt;/&lt;/span&gt;data&lt;span style="color: #808030;"&gt;.&lt;/span&gt;txt&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
with specifying original path to store files at.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To get files you need to reverse&amp;nbsp;paths&amp;nbsp;given via arguments to &lt;b&gt;scp&lt;/b&gt;. E.g.:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;scp garmoncheg&lt;span style="color: #808030;"&gt;.&lt;/span&gt;google&lt;span style="color: #808030;"&gt;.&lt;/span&gt;com&lt;span style="color: purple;"&gt;:&lt;/span&gt;data&lt;span style="color: #808030;"&gt;.&lt;/span&gt;txt file&lt;span style="color: #808030;"&gt;.&lt;/span&gt;txt&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
This will copy file from your default ssh directory named "data.txt" to local (current directory) file called "file.txt"&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To work with directory (get/put files) recursively there is an &lt;b&gt;-r &lt;/b&gt;switch:&lt;/div&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;scp &lt;span style="color: #808030;"&gt;-&lt;/span&gt;r project&lt;span style="color: #808030;"&gt;-&lt;/span&gt;stage&lt;span style="color: purple;"&gt;:&lt;/span&gt;logfiles &lt;span style="color: #808030;"&gt;/&lt;/span&gt;home&lt;span style="color: #808030;"&gt;/&lt;/span&gt;garmoncheg&lt;span style="color: #808030;"&gt;/&lt;/span&gt;logfiles&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
This will download directory "logfiles" from server with ssh shortcut "project-stage" into current directory naming it "logfiles"&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That's it. There are many more&amp;nbsp;decisions&amp;nbsp;and recipes for those typical enough operations. Dont hesitate to comment with yours ;)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/jcxjWt84ckY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/239610826370117935/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/09/ssh-unixlunux-recipes-for-daily-usage.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/239610826370117935?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/239610826370117935?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/jcxjWt84ckY/ssh-unixlunux-recipes-for-daily-usage.html" title="SSH Unix/Lunux Recipes for daily usage." /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-EMOUjVNF2kc/UFoNDEvTIgI/AAAAAAAAFZU/d8--9TPKPeU/s72-c/111.jpg" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Voli Ave, 2, Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.5863735 25.009525999999997 50.9080925 25.64124</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/09/ssh-unixlunux-recipes-for-daily-usage.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkAESHc4fip7ImA9WhJXEk4.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-8078955785650673635</id><published>2012-08-06T10:38:00.000+03:00</published><updated>2012-08-06T10:38:29.936+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-06T10:38:29.936+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="execution" /><category scheme="http://www.blogger.com/atom/ns#" term="logging" /><category scheme="http://www.blogger.com/atom/ns#" term="time" /><category scheme="http://www.blogger.com/atom/ns#" term="measure" /><category scheme="http://www.blogger.com/atom/ns#" term="recipe" /><category scheme="http://www.blogger.com/atom/ns#" term="log" /><category scheme="http://www.blogger.com/atom/ns#" term="decision" /><category scheme="http://www.blogger.com/atom/ns#" term="datetime" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="simple" /><category scheme="http://www.blogger.com/atom/ns#" term="console" /><category scheme="http://www.blogger.com/atom/ns#" term="nice" /><category scheme="http://www.blogger.com/atom/ns#" term="straightforward" /><title>Python: simple recipe to measure your function's execution time</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-ADKsI35M8pY/UB90YuNrR5I/AAAAAAAAFY0/TTaZ4MUx3Y0/s1600/clock.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-ADKsI35M8pY/UB90YuNrR5I/AAAAAAAAFY0/TTaZ4MUx3Y0/s1600/clock.png" /&gt;&lt;/a&gt;&lt;/div&gt;
We always write something unusual while doing basic things. Our own bicycles and crutches to work out some unusual situation. Here is another recipe to do a thing like so. I have tried several libraries and readymade decisions. But it assumes you have them installed. And you often try things in console, don't you?&lt;br /&gt;
&lt;br /&gt;
Anyway the recipe is simple and quite straightforward.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; datetime

&lt;span style="color: #b96969;"&gt;# Getting first timestamp&lt;/span&gt;
t1 &lt;span style="color: #808030;"&gt;=&lt;/span&gt; datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;now&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# Your function e.g.:&lt;/span&gt;
data &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;g&lt;span style="color: #808030;"&gt;.&lt;/span&gt;name &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; g &lt;span style="color: #508050; font-weight: bold;"&gt;in&lt;/span&gt; request&lt;span style="color: #808030;"&gt;.&lt;/span&gt;user&lt;span style="color: #808030;"&gt;.&lt;/span&gt;groups&lt;span style="color: #808030;"&gt;.&lt;/span&gt;all&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# Second timestamp&lt;/span&gt;
t2 &lt;span style="color: #808030;"&gt;=&lt;/span&gt; datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;now&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #508050; font-weight: bold;"&gt;print&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;"Execution time: %s"&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;t1&lt;span style="color: #808030;"&gt;-&lt;/span&gt;t2&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
It is rude and quite simple but may often suit you well to measure execution time in a simple and straightforward manner.&lt;br /&gt;
Also nice idea to write down this function into logs. It may be handy on refactoring of your core app for e.g.;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; datetime
&lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; logging
log &lt;span style="color: #808030;"&gt;=&lt;/span&gt; logging&lt;span style="color: #808030;"&gt;.&lt;/span&gt;getLogger&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'mylogger'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #b96969;"&gt;# Getting first timestamp&lt;/span&gt;
t1 &lt;span style="color: #808030;"&gt;=&lt;/span&gt; datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;now&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# Your function e.g.:&lt;/span&gt;
data &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;g&lt;span style="color: #808030;"&gt;.&lt;/span&gt;name &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; g &lt;span style="color: #508050; font-weight: bold;"&gt;in&lt;/span&gt; request&lt;span style="color: #808030;"&gt;.&lt;/span&gt;user&lt;span style="color: #808030;"&gt;.&lt;/span&gt;groups&lt;span style="color: #808030;"&gt;.&lt;/span&gt;all&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# Second timestamp&lt;/span&gt;
t2 &lt;span style="color: #808030;"&gt;=&lt;/span&gt; datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;now&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# Using Logging to write down calls&lt;/span&gt;
log&lt;span style="color: #808030;"&gt;.&lt;/span&gt;debug&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"my_function Execution time: %s"&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;t1&lt;span style="color: #808030;"&gt;-&lt;/span&gt;t2&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
This also can grow up to Django decorator that can log time of function&amp;nbsp;execution&amp;nbsp;into console/log file/whatever. But it's quite another story.&lt;br /&gt;
Those snippets are quite Django based. But, I think, the core is pure python, if you've got the core concept of this. &lt;br /&gt;
&lt;br /&gt;
Used, have thoughts, know how to do it in a better/simpler manner? I'm wrong? Please comment!&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/hsmJ8EFx7Oo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/8078955785650673635/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/08/python-simple-recipe-to-measure-your.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/8078955785650673635?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/8078955785650673635?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/hsmJ8EFx7Oo/python-simple-recipe-to-measure-your.html" title="Python: simple recipe to measure your function's execution time" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-ADKsI35M8pY/UB90YuNrR5I/AAAAAAAAFY0/TTaZ4MUx3Y0/s72-c/clock.png" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.666856 25.167454499999998 50.82761 25.4833115</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/08/python-simple-recipe-to-measure-your.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MAQno4cSp7ImA9WhBSGUU.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-1744694436543795136</id><published>2012-07-21T16:55:00.001+03:00</published><updated>2013-02-27T19:17:23.439+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-27T19:17:23.439+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tools" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="password" /><category scheme="http://www.blogger.com/atom/ns#" term="django-password-reset" /><category scheme="http://www.blogger.com/atom/ns#" term="reset" /><category scheme="http://www.blogger.com/atom/ns#" term="method" /><category scheme="http://www.blogger.com/atom/ns#" term="contrib" /><category scheme="http://www.blogger.com/atom/ns#" term="auth" /><category scheme="http://www.blogger.com/atom/ns#" term="django-registration" /><category scheme="http://www.blogger.com/atom/ns#" term="forms" /><category scheme="http://www.blogger.com/atom/ns#" term="decision" /><category scheme="http://www.blogger.com/atom/ns#" term="email" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>Django: Resetting Passwords (with internal tools)</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-sRJk_rqKyrk/UAqzsHNdVSI/AAAAAAAAFYU/QYi7-nCrNe4/s1600/Key.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://1.bp.blogspot.com/-sRJk_rqKyrk/UAqzsHNdVSI/AAAAAAAAFYU/QYi7-nCrNe4/s200/Key.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
I have had a task recently. It was about adding a forms/mechanism for resetting a password in our Django based project. We have had our own registration system ongoing... It's a corporate sector project. So you can not go and register yourself. Admins (probably via LDAP sync) will register your email/login in system. So you have to go there and only set yourself a password. For security reasons you can not register. One word.&lt;br /&gt;
&lt;br /&gt;
First I've tried to find standart&amp;nbsp;decision. From reviewed by me were: &lt;a href="http://pypi.python.org/pypi/django-registration/"&gt;django-registration&lt;/a&gt; and &lt;a href="https://github.com/brutasse/django-password-reset"&gt;django password-reset&lt;/a&gt;. These are nice tools to install and give it a go. But I've needed a more complex decision. And the idea was that own bicycle is always better. So I've thought of django admin and that it has all the things you need to do this yourself in no time. (Actually it's &lt;a href="https://github.com/django/django/blob/master/django/contrib/auth/views.py"&gt;django.contrib.auth&lt;/a&gt; part of django, but used out of the box in Admin UI) You can find views you need for this in there. they are:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;span style="background-color: white;"&gt;password_reset&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background-color: white;"&gt;password_reset_done&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background-color: white;"&gt;password_reset_confirm&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background-color: white;"&gt;password_reset_complete&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
To use this method you need:&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;

1. Emails config:&lt;/h4&gt;
Your typical Django project has settings.py variables to be set for enabling SMTP server. Usually you need this on production to send admins emails about 500 errors and/or system warnings. For our needs python has an internal mail server. I prefer to use it for debug purposes. So good method would be to use it only in Debug case. You can do it by adding those lines to your settings.py:&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;if&lt;/span&gt; DEBUG&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    EMAIL_HOST &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'localhost'&lt;/span&gt;
    EMAIL_PORT &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #778c77;"&gt;1025&lt;/span&gt;
    EMAIL_HOST_USER &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;
    EMAIL_HOST_PASSWORD &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;
    EMAIL_USE_TLS &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;False&lt;/span&gt;
    DEFAULT_FROM_EMAIL &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'testing@example.com'&lt;/span&gt;&lt;/pre&gt;
Here you will have this custom email server set to alternative port. For production you should enter your Sendmail (or whatever you use there)&amp;nbsp;parameters...&lt;br /&gt;
&lt;br /&gt;
Now you will be able to start it running the terminal and executing:&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;python &lt;span style="color: #808030;"&gt;-&lt;/span&gt;m smtpd &lt;span style="color: #808030;"&gt;-&lt;/span&gt;n &lt;span style="color: #808030;"&gt;-&lt;/span&gt;c DebuggingServer localhost&lt;span style="color: purple;"&gt;:&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1025&lt;/span&gt;&lt;/pre&gt;
You can also read abut it &lt;a href="http://garmoncheg.blogspot.com/2011/11/python-debuggingdeveloping-smtp-mail.html"&gt;here&lt;/a&gt;. You will be able to copy/paste email links that should be sent via Django email.&amp;nbsp;&lt;span style="background-color: white;"&gt;Now that you have everything setup for experiments...&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;h4 style="text-align: left;"&gt;

&lt;span style="background-color: white;"&gt;2. Config Url's:&lt;/span&gt;&lt;/h4&gt;
&lt;span style="background-color: white;"&gt;&lt;b&gt;urls.py&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;urlpatterns &lt;span style="color: #808030;"&gt;=&lt;/span&gt; patterns&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    url&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r'^user/password/reset/$'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
        &lt;span style="color: #cc5555;"&gt;'django.contrib.auth.views.password_reset'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
        &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'post_reset_redirect'&lt;/span&gt; &lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'/user/password/reset/done/'&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
        name&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"password_reset"&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r'^user/password/reset/done/$'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
        &lt;span style="color: #cc5555;"&gt;'django.contrib.auth.views.password_reset_done'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r'^user/password/reset/(?P&amp;lt;uidb36&amp;gt;[0-9A-Za-z]+)-(?P&amp;lt;token&amp;gt;.+)/$'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
        &lt;span style="color: #cc5555;"&gt;'django.contrib.auth.views.password_reset_confirm'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
        &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'post_reset_redirect'&lt;/span&gt; &lt;span style="color: #808030;"&gt;:&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'/user/password/done/'&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;r'^user/password/done/$'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
        &lt;span style="color: #cc5555;"&gt;'django.contrib.auth.views.password_reset_complete'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# ...&lt;/span&gt;
&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;h4 style="text-align: left;"&gt;

3. Add Templates:&lt;/h4&gt;
You have templates for your reset password forms already. Django admin templates/css/js are used there. But I think you would want custom one's for your needs. SO basically all you may need is overriding those templates, specified down here and place them on your&amp;nbsp;&lt;span style="background-color: white;"&gt;templates&lt;/span&gt;&lt;span style="background-color: white;"&gt;&amp;nbsp;Django&lt;/span&gt;&lt;span style="background-color: white;"&gt;&amp;nbsp;path.&lt;/span&gt;&lt;br /&gt;
You need to override:&lt;br /&gt;
&lt;i&gt;Django templates:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;i style="background-color: white;"&gt;registration/password_reset_form.html&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i style="background-color: white;"&gt;&lt;i style="background-color: white;"&gt;registration/password_reset_done.html&lt;/i&gt;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i style="background-color: white;"&gt;registration/password_reset_confirm.html&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i style="background-color: white;"&gt;registration/password_reset_complete.html&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;i&gt;Email template:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;i style="background-color: white;"&gt;registration/password_reset_email.html&amp;nbsp;&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
I'll write down here one's I've used, according to Django's "Batteries&amp;nbsp;included" philosophy.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;registration/password_reset_form.html&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;{% extends "base&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;html" %}

{% block title %}Reset Password{% endblock %}

{% block content %}
&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Please specify your email address to receive instructions for resetting it&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;

&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;form&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;action&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;""&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;method&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"post"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;style&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"&lt;/span&gt;&lt;span style="color: #bb7977; font-weight: bold;"&gt;display&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;&lt;span style="color: #477766;"&gt;none&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;input&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;type&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"hidden"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;value&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"{{ csrf_token }}"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;name&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"csrfmiddlewaretoken"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
     {{ form&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;email&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;errors }}
    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;for&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"id_email"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;E-mail address:&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt; {{ form&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;email }} &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;input&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;type&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"submit"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;value&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"Reset password"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #865700;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;form&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
{% endblock %}&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;registration/password_reset_done.html&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;{% extends "base&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;html" %}

{% block title %}Password reset successful{% endblock %}

{% block content %}
&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;We've e-mailed you instructions for setting your password to the e-mail address you submitted&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;You should be receiving it shortly&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
{% endblock %}&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;registration/password_reset_confirm.html&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;{% extends "base&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;html" %}
{% block title %}Setting New password{% endblock %}

{% block content %}
    {% if validlink %}
        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Please enter your new password twice&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;br&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #865700;"&gt;/&amp;gt;&lt;/span&gt;
           So we can verify you typed it in correctly&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;form&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;action&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;""&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;method&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"post"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
            &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;style&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"&lt;/span&gt;&lt;span style="color: #bb7977; font-weight: bold;"&gt;display&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;&lt;span style="color: #477766;"&gt;none&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;input&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;type&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"hidden"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;value&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"{{ csrf_token }}"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;name&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"csrfmiddlewaretoken"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
            &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
            &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;table&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;tr&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;{{ form&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;new_password1&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;errors }}
                        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;for&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"id_new_password1"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;New password:&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;{{ form&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;new_password1 }}&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;tr&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;tr&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;{{ form&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;new_password2&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;errors }}
                        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;for&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"id_new_password2"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Confirm password:&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;{{ form&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;new_password2 }}&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;tr&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;tr&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;input&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;type&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"submit"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;value&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"Change my password"&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #865700;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;td&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
                &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;tr&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
            &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;table&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;form&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
    {% else %}
        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;h1&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Password reset unsuccessful&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;h1&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;The password reset link was invalid, &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;br&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #865700;"&gt;/&amp;gt;&lt;/span&gt;
        possibly because it has already been used&lt;span style="color: #778c77;"&gt;.&lt;/span&gt; &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;br&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #865700;"&gt;/&amp;gt;&lt;/span&gt;
        Please request a new password reset&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
    {% endif %}
{% endblock %}&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;registration/password_reset_complete.html&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;{% extends "base&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;html" %}

{% block title %}Password reset complete{% endblock %}

{% block content %}
&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Your password has been set&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;  You may go ahead and log in now&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;a&lt;/span&gt;&lt;span style="color: #477766;"&gt; &lt;/span&gt;&lt;span style="color: #477766;"&gt;href&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"{{ login_url }}"&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Log in&amp;lt;/a&amp;gt;&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;p&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
{% endblock %}&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;registration/password_reset_email.html&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;{% autoescape off %}
You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.

Please go to the following page and choose a new password:
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url django&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;contrib&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;auth&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;views&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;password_reset_confirm uidb36=uid, token=token %}
{% endblock %}

Your username, in case you've forgotten: {{ user&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;username }}

Thanks for using our site!

The {{ site_name }} team&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;

{% endautoescape %}&lt;/pre&gt;
&lt;br /&gt;
SO you're getting password reset system out of the box using only Django included tools. In no time.&lt;br /&gt;
Comment me...!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/1ESOWMaCQMY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/1744694436543795136/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/07/django-resetting-passwords-with.html#comment-form" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1744694436543795136?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1744694436543795136?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/1ESOWMaCQMY/django-resetting-passwords-with.html" title="Django: Resetting Passwords (with internal tools)" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-sRJk_rqKyrk/UAqzsHNdVSI/AAAAAAAAFYU/QYi7-nCrNe4/s72-c/Key.png" height="72" width="72" /><thr:total>12</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/07/django-resetting-passwords-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEGRHkzeCp7ImA9WhJRE0k.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-7614455880481042338</id><published>2012-07-15T12:22:00.000+03:00</published><updated>2012-07-15T12:30:25.780+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-15T12:30:25.780+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="HttpResponse" /><category scheme="http://www.blogger.com/atom/ns#" term="method" /><category scheme="http://www.blogger.com/atom/ns#" term="HttpResponseRedirect" /><category scheme="http://www.blogger.com/atom/ns#" term="test" /><category scheme="http://www.blogger.com/atom/ns#" term="unitest" /><category scheme="http://www.blogger.com/atom/ns#" term="recipe" /><category scheme="http://www.blogger.com/atom/ns#" term="TDD" /><category scheme="http://www.blogger.com/atom/ns#" term="regexp" /><category scheme="http://www.blogger.com/atom/ns#" term="djago" /><category scheme="http://www.blogger.com/atom/ns#" term="unittests" /><category scheme="http://www.blogger.com/atom/ns#" term="testing" /><category scheme="http://www.blogger.com/atom/ns#" term="redirect" /><category scheme="http://www.blogger.com/atom/ns#" term="view" /><title>Django: Unittest for HttpResponseRedirect method recipe</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: right;"&gt;
&lt;a href="http://4.bp.blogspot.com/-Zhqw0CXi-LI/UAKLkaajn4I/AAAAAAAAFYI/n-Aorou-78k/s1600/302-redirect.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://4.bp.blogspot.com/-Zhqw0CXi-LI/UAKLkaajn4I/AAAAAAAAFYI/n-Aorou-78k/s200/302-redirect.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
I like to invent bicycles in my code. They often come in handy and you basically do not rely on Django version... So upon updating your project's Django version in future times you will not have to refactor half of all the code. So...&lt;br /&gt;
&lt;br /&gt;
How do you test http redirects? I usually restrict&amp;nbsp;my time in thinking and write code like if redirect target is hardcoded. And it really is in most of the times. But imagine if you decide to redirect your view response in several&amp;nbsp;places. Or imagine if you're not the only one who owns you'r project's code and there are many collaborators that can change things without&amp;nbsp;warning... And you need to have a test for that view that will test redirects and complex code&amp;nbsp;behavior.&lt;br /&gt;
&lt;br /&gt;
I used to check redirects like so:&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;response &lt;span style="color: #808030;"&gt;=&lt;/span&gt; self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;cliet&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'/myview'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;assertEqual&lt;span style="color: #808030;"&gt;(&lt;/span&gt;response&lt;span style="color: #808030;"&gt;.&lt;/span&gt;status_code&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #778c77;"&gt;302&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# View redirected... All ok...&lt;/span&gt;&lt;/pre&gt;
But &amp;nbsp;if you have some view that can redirect to things that you need to check. How would you test that? &amp;nbsp;E.g. your view:&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; random

&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; myview&lt;span style="color: #808030;"&gt;(&lt;/span&gt;request&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    url_end &lt;span style="color: #808030;"&gt;=&lt;/span&gt; random&lt;span style="color: #808030;"&gt;.&lt;/span&gt;choice&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;3&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;4&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    url &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'/someplace/'&lt;/span&gt; &lt;span style="color: #808030;"&gt;+&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;str&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;url_end&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;return&lt;/span&gt; HttpResponseRedirect&lt;span style="color: #808030;"&gt;(&lt;/span&gt;url&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
It can produce many urls and you basically can not predict which one it will produce this time. Maybe it's not the best example. However it's quite simple and understandable IMHO. You're view can redirect you to:&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #cc5555;"&gt;/someplace/1&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;pre&gt;&lt;span style="color: #cc5555;"&gt;/someplace/2&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="color: #cc5555;"&gt;...&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
Imagine if your program results may depend on that and you must check if the page rendering is properly relayed on that URL that you're redirecting.&lt;br /&gt;
&lt;br /&gt;
How would you check that without relying much into Django variables and producing hacks? Exactly! You name it... Regexp's:&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; MyTestCase&lt;span style="color: #808030;"&gt;(&lt;/span&gt;TestCase&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; setUp&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# We are using only logged in client in this test&lt;/span&gt;
        self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;client&lt;span style="color: #808030;"&gt;.&lt;/span&gt;login&lt;span style="color: #808030;"&gt;(&lt;/span&gt;username&lt;span style="color: #808030;"&gt;=&lt;/span&gt;username&lt;span style="color: #808030;"&gt;,&lt;/span&gt; password&lt;span style="color: #808030;"&gt;=&lt;/span&gt;password&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; test_mytest&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        response &lt;span style="color: #808030;"&gt;=&lt;/span&gt; self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;client&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get&lt;span style="color: #808030;"&gt;(&lt;/span&gt;reverse&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'myview'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# Following redirect in tests&lt;/span&gt;
        new_url &lt;span style="color: #808030;"&gt;=&lt;/span&gt; self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;_retrieve_redirect_response_url&lt;span style="color: #808030;"&gt;(&lt;/span&gt;response&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        response &lt;span style="color: #808030;"&gt;=&lt;/span&gt; self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;client&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get&lt;span style="color: #808030;"&gt;(&lt;/span&gt;new_url&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;assertEqual&lt;span style="color: #808030;"&gt;(&lt;/span&gt;response&lt;span style="color: #808030;"&gt;.&lt;/span&gt;status_code&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #778c77;"&gt;200&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# No errors appeared&lt;/span&gt;
 
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; _retrieve_redirect_response_url&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;,&lt;/span&gt; response&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;"""&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;My handy helper:&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parses 302 response object.&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Returns redirect url, parsed by regex.&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"""&lt;/span&gt;
        self&lt;span style="color: #808030;"&gt;.&lt;/span&gt;assertEqual&lt;span style="color: #808030;"&gt;(&lt;/span&gt;response&lt;span style="color: #808030;"&gt;.&lt;/span&gt;status_code&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #778c77;"&gt;302&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        new_url &lt;span style="color: #808030;"&gt;=&lt;/span&gt; re&lt;span style="color: #808030;"&gt;.&lt;/span&gt;search&lt;span style="color: #808030;"&gt;(&lt;/span&gt;
                            &lt;span style="color: #b96969;"&gt;# Our REGEXP:&lt;/span&gt;
                            &lt;span style="color: #cc5555;"&gt;"(?P&amp;lt;url&amp;gt;https?://[^\s]+)"&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
                            &lt;span style="color: #e34adc;"&gt;str&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;response&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;group&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"url"&lt;/span&gt;
                            &lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;return&lt;/span&gt; new_url&lt;/pre&gt;
A lot of third party logic exists in this test. But it's partially a live tests snippet with names changed. So you may assume it should be like so and concentrate your thoughts on this approach in general, rather than possible inconsistencies.&lt;br /&gt;
&lt;br /&gt;
Main deed does regexp:&amp;nbsp;&lt;span style="background-color: #001800; color: #cc5555; text-align: -webkit-auto;"&gt;"(?P&amp;lt;url&amp;gt;https?://[^\s]+)"&lt;/span&gt;&lt;span style="background-color: white;"&gt;. Other code is only possible solution to use it in a handy way... &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Anyway, now you can use this snippet in your code to check url that view redirected you to. Only concern that I have here that there are much simpler approaches. But this one is almost Django updates independent. It stringifies your response and parses for url there.&lt;br /&gt;
&lt;br /&gt;
If you want to know about re.search more:&amp;nbsp;&lt;a href="http://docs.python.org/howto/regex.html"&gt;http://docs.python.org/howto/regex.html&lt;/a&gt;&lt;br /&gt;
Writing tests in general:&amp;nbsp;&lt;a href="https://docs.djangoproject.com/en/dev/topics/testing/?from=olddocs"&gt;https://docs.djangoproject.com/en/dev/topics/testing/?from=olddocs&lt;/a&gt;&lt;br /&gt;
Hope this will help someone.&amp;nbsp;Comment&amp;nbsp;your ideas on this!&amp;nbsp;Appreciate&amp;nbsp;your every thought...&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/M3_O7GlHGQg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/7614455880481042338/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/07/django-unittest-for-httpresponseredirec.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/7614455880481042338?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/7614455880481042338?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/M3_O7GlHGQg/django-unittest-for-httpresponseredirec.html" title="Django: Unittest for HttpResponseRedirect method recipe" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-Zhqw0CXi-LI/UAKLkaajn4I/AAAAAAAAFYI/n-Aorou-78k/s72-c/302-redirect.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://garmoncheg.blogspot.com/2012/07/django-unittest-for-httpresponseredirec.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEDSXk4eSp7ImA9WhJSGE4.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-4805104716372564816</id><published>2012-07-09T13:36:00.000+03:00</published><updated>2012-07-09T13:44:38.731+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-09T13:44:38.731+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="grant" /><category scheme="http://www.blogger.com/atom/ns#" term="access" /><category scheme="http://www.blogger.com/atom/ns#" term="free" /><category scheme="http://www.blogger.com/atom/ns#" term="iPad" /><category scheme="http://www.blogger.com/atom/ns#" term="iPhone" /><category scheme="http://www.blogger.com/atom/ns#" term="contacts" /><category scheme="http://www.blogger.com/atom/ns#" term="tweak" /><category scheme="http://www.blogger.com/atom/ns#" term="Cydia" /><category scheme="http://www.blogger.com/atom/ns#" term="twitter" /><category scheme="http://www.blogger.com/atom/ns#" term="jailbreak" /><category scheme="http://www.blogger.com/atom/ns#" term="Skype" /><category scheme="http://www.blogger.com/atom/ns#" term="Apple" /><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft" /><category scheme="http://www.blogger.com/atom/ns#" term="privacy" /><category scheme="http://www.blogger.com/atom/ns#" term="private" /><category scheme="http://www.blogger.com/atom/ns#" term="Facebook" /><category scheme="http://www.blogger.com/atom/ns#" term="Linkedin" /><category scheme="http://www.blogger.com/atom/ns#" term="iOS" /><category scheme="http://www.blogger.com/atom/ns#" term="ContactPrivacy" /><title>Blocking iOS to acces Contacts freely</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-QVyjOzHlG38/T_qwXCfdvvI/AAAAAAAAFX4/7r8MjgwpSyM/s1600/Screen+Shot+2012-07-09+at+1.19.18+PM.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/-QVyjOzHlG38/T_qwXCfdvvI/AAAAAAAAFX4/7r8MjgwpSyM/s200/Screen+Shot+2012-07-09+at+1.19.18+PM.png" width="188" /&gt;&lt;/a&gt;&lt;/div&gt;
There are lots of occasions when you want to be private in the net. Now it's common to say "Anonymous". Many people do not even think it's important. I, personaly, dislike facebook, skype, twitter, any else third party... having my contacts list synched to their server without even telling me...&amp;nbsp;&lt;span style="background-color: white;"&gt;I do not want to be truly anonymous, you know... Have nothing to hide really. But I want that really smal confirm that Skype, for e.g. would take my contacts and for what reason.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Facebook was first, as usual... They've done it. I really deleted their app from my iOS devices first. But instead of taking lessons from their mistakes... All huge companies gone wild about this possibility to copy some new ammount of user data... Skype was second (for me)... Then LinkedIn... However they warned and I've agreed... So nothing really bad to say about them. But MS is such a Microsoft... They want me to "skype" instead of "calling" my friends through my Apple/Android device :)...&lt;br /&gt;
&lt;br /&gt;
Anyway I've decided I really need something like a hardware switch to grant access to my contact list on iDevices... And it is really done for us already...&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;You need a Jailbreak for this! &lt;/b&gt;(As I had one already wont mention it here. I&amp;nbsp;think&amp;nbsp;there are lots of info in the net about it)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ContactPrivacy&lt;/b&gt; tweak. For now, that I'm writing this article... It exists in BigBoss repo, that is default set in Cydia AFAIK. And you suppose to have access to it without adding any repositories. So typing in Cydia search: "ContactPrivacy" (without scopes) should reveal it without any problems.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-O6JpNjacaZE/T_qvw_WpA-I/AAAAAAAAFXw/mzcwc9FGCj4/s1600/cp.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-O6JpNjacaZE/T_qvw_WpA-I/AAAAAAAAFXw/mzcwc9FGCj4/s320/cp.jpg" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
After installing it you will&amp;nbsp;probably&amp;nbsp;see something like this:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-NHDL2fFfjRQ/T_qseT4oMwI/AAAAAAAAFXk/lQqyrKgSDmw/s1600/contacts.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-NHDL2fFfjRQ/T_qseT4oMwI/AAAAAAAAFXk/lQqyrKgSDmw/s1600/contacts.png" /&gt;&lt;/a&gt;&lt;/div&gt;
So ...... you Skype after installing it. :)&lt;br /&gt;
&lt;br /&gt;
Note: That I think it's good idea to install this tweak even before any other APP is installed. I'd do so if I only knew before.&lt;br /&gt;
&lt;br /&gt;
Heard somewhere about&amp;nbsp;Twitter&amp;nbsp;is going to have my contacts too... Wtf? Why Twitter wants them too... Can't even imagine... Who's next. "Corporation of all good". Nahh... I think they already have them but not so dumb to tell &amp;gt;:) But somehow it does disturb me less...&lt;br /&gt;
&lt;br /&gt;
BTW it's a nice reason to make a jailbreak for this tweak. Why not make it standard in iOS?&lt;br /&gt;
&lt;span style="background-color: white;"&gt;How do you think?&lt;/span&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/ugSucneGaLQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/4805104716372564816/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/07/blocking-ios-to-acces-contacts-freely.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4805104716372564816?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4805104716372564816?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/ugSucneGaLQ/blocking-ios-to-acces-contacts-freely.html" title="Blocking iOS to acces Contacts freely" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-QVyjOzHlG38/T_qwXCfdvvI/AAAAAAAAFX4/7r8MjgwpSyM/s72-c/Screen+Shot+2012-07-09+at+1.19.18+PM.png" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/07/blocking-ios-to-acces-contacts-freely.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MCSXw7eyp7ImA9WhJTF00.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-4330466314346237196</id><published>2012-06-26T12:04:00.000+03:00</published><updated>2012-06-26T12:04:28.203+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-26T12:04:28.203+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="solve" /><category scheme="http://www.blogger.com/atom/ns#" term="login" /><category scheme="http://www.blogger.com/atom/ns#" term="problem" /><category scheme="http://www.blogger.com/atom/ns#" term="preferences" /><category scheme="http://www.blogger.com/atom/ns#" term="unauthorized" /><category scheme="http://www.blogger.com/atom/ns#" term="twitter" /><category scheme="http://www.blogger.com/atom/ns#" term="mac" /><category scheme="http://www.blogger.com/atom/ns#" term="authentication" /><category scheme="http://www.blogger.com/atom/ns#" term="official" /><category scheme="http://www.blogger.com/atom/ns#" term="client" /><title>Twitter official client for Mac problem "Unauthorized" solving.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I had a problem "Unauthorized"&amp;nbsp;in official twitter client for Mac.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-c58rK4eNQX8/T-l6DiamaxI/AAAAAAAAFXQ/ED2ipb_-hnI/s1600/111.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-c58rK4eNQX8/T-l6DiamaxI/AAAAAAAAFXQ/ED2ipb_-hnI/s1600/111.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Tried several instal/reinstall. Deleted/Downloaded again from Apple App Store. It all didn't help. They seem to change something in authentication. So I've tried deleting all the config files in ~/Library/&lt;br /&gt;
Main solution that helped me:&lt;br /&gt;
1. Switch off the client. (be sure to Close an app)&lt;br /&gt;
2. Delete:&lt;br /&gt;
&lt;br /&gt;
~/Library/Preferences/com.twitter.twitter-mac.plist.lockfile&lt;br /&gt;
&lt;div&gt;
~/Library/Preferences/com.twitter.twitter-mac.plist&lt;/div&gt;
&lt;div&gt;
3. Launch Twitter app and login from scratch.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I have&amp;nbsp;revoked&amp;nbsp;access&amp;nbsp;this twitter client too in my &lt;a href="https://twitter.com/settings/applications"&gt;https://twitter.com/settings/applications&lt;/a&gt;&amp;nbsp;but it seem to make no effect.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Making similar actions to TweetDeck for Mac does not help. So it seems like problem is somewhere deeper. Hope it will help you solve similar issue.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/HJLCPYuAmq0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/4330466314346237196/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/06/twitter-official-client-for-mac-problem.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4330466314346237196?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4330466314346237196?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/HJLCPYuAmq0/twitter-official-client-for-mac-problem.html" title="Twitter official client for Mac problem &quot;Unauthorized&quot; solving." /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-c58rK4eNQX8/T-l6DiamaxI/AAAAAAAAFXQ/ED2ipb_-hnI/s72-c/111.png" height="72" width="72" /><thr:total>6</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/06/twitter-official-client-for-mac-problem.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAESH08eCp7ImA9WhJTFkg.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-4477014536465308382</id><published>2012-06-19T14:01:00.002+03:00</published><updated>2012-06-25T22:48:29.370+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-25T22:48:29.370+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="visual" /><category scheme="http://www.blogger.com/atom/ns#" term="better" /><category scheme="http://www.blogger.com/atom/ns#" term="pretty" /><category scheme="http://www.blogger.com/atom/ns#" term="log" /><category scheme="http://www.blogger.com/atom/ns#" term="git" /><category scheme="http://www.blogger.com/atom/ns#" term="config" /><category scheme="http://www.blogger.com/atom/ns#" term="terminal" /><category scheme="http://www.blogger.com/atom/ns#" term="nice" /><category scheme="http://www.blogger.com/atom/ns#" term="console" /><title>Pretty git Log</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
SO you dislike git log output in console like me and do not use it... Because it looks like so:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-zgGcw9efrMg/T-BaUe6qGEI/AAAAAAAAFS0/I_8QaEKkOzU/s1600/Screen+Shot+2012-06-19+at+1.52.26+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="177" src="http://2.bp.blogspot.com/-zgGcw9efrMg/T-BaUe6qGEI/AAAAAAAAFS0/I_8QaEKkOzU/s320/Screen+Shot+2012-06-19+at+1.52.26+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
How about this one?&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-40kOKf0oMR0/T-BafN4FC_I/AAAAAAAAFTA/wvF9vhE2N6w/s1600/Screen+Shot+2012-06-19+at+1.52.51+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://1.bp.blogspot.com/-40kOKf0oMR0/T-BafN4FC_I/AAAAAAAAFTA/wvF9vhE2N6w/s320/Screen+Shot+2012-06-19+at+1.52.51+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
It's quite easy...&lt;br /&gt;
Just type:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;git log &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;graph &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;pretty&lt;span style="color: #808030;"&gt;=&lt;/span&gt;format&lt;span style="color: #808030;"&gt;:&lt;/span&gt;'%Cred%h%Creset -%C&lt;span style="color: #808030;"&gt;(&lt;/span&gt;yellow&lt;span style="color: #808030;"&gt;)&lt;/span&gt;%d%Creset %s %Cgreen&lt;span style="color: #808030;"&gt;(&lt;/span&gt;%cr) %C&lt;span style="color: #808030;"&gt;(&lt;/span&gt;bold blue&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&amp;lt;%an&amp;gt;%Creset' &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;abbrev&lt;span style="color: #808030;"&gt;-&lt;/span&gt;commit &lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
It may be hard to enter such an easy command every time. Let's make an alias instead... Copypaste this to your terminal:&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;




&lt;span style="font-weight: normal;"&gt;git config --global alias.lg "log --color --graph 
--pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) 
%C(bold blue)&amp;lt;%an&amp;gt;%Creset' --abbrev-commit --"&lt;/span&gt;&lt;/h3&gt;
And use simple command to see this pretty log instead:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;git lg&lt;/pre&gt;
&lt;br /&gt;
Now in case you want to see lines that changed use:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;git lg &lt;span style="color: #808030;"&gt;-&lt;/span&gt;p&lt;/pre&gt;
In order for this command to work remove&amp;nbsp;&lt;span style="background-color: white;"&gt;the -- from the end of the alias.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
May the code be with you!&lt;br /&gt;
&lt;br /&gt;
NOTE: this article is a&amp;nbsp;rewritten&amp;nbsp;copy of&amp;nbsp;&lt;a href="http://coderwall.com/p/euwpig?i=3&amp;amp;p=1&amp;amp;t=git"&gt;http://coderwall.com/p/euwpig?i=3&amp;amp;p=1&amp;amp;t=git&lt;/a&gt;&amp;nbsp;&lt;span style="background-color: white;"&gt;and have been put here only in purpose of note to myself. &amp;nbsp;However you may use for your own needs...&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;UPD2: And unless you're a contributor of the git project and have written at least part of original code and/or documentation that does this trick... Then you&amp;nbsp;probably&amp;nbsp;stole the idea. ;) (IMHO)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/WAdwjs6sObQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/4477014536465308382/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html#comment-form" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4477014536465308382?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4477014536465308382?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/WAdwjs6sObQ/pretty-git-log.html" title="Pretty git Log" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-zgGcw9efrMg/T-BaUe6qGEI/AAAAAAAAFS0/I_8QaEKkOzU/s72-c/Screen+Shot+2012-06-19+at+1.52.26+PM.png" height="72" width="72" /><thr:total>9</thr:total><feedburner:origLink>http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUAEQX87fCp7ImA9WhVaEEQ.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-3813237032343002854</id><published>2012-06-07T22:35:00.000+03:00</published><updated>2012-06-07T22:35:00.104+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-07T22:35:00.104+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tuple" /><category scheme="http://www.blogger.com/atom/ns#" term="patterns" /><category scheme="http://www.blogger.com/atom/ns#" term="howto" /><category scheme="http://www.blogger.com/atom/ns#" term="sort()" /><category scheme="http://www.blogger.com/atom/ns#" term="pattern" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="simple" /><category scheme="http://www.blogger.com/atom/ns#" term="list" /><category scheme="http://www.blogger.com/atom/ns#" term="basic" /><category scheme="http://www.blogger.com/atom/ns#" term="sort" /><category scheme="http://www.blogger.com/atom/ns#" term="dictionary" /><title>Python sort() patterns</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-0kGfXm4j22c/T9CtSUwUTCI/AAAAAAAAFO4/X3r2F3nt7P0/s1600/SortingSmall.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="150" src="http://3.bp.blogspot.com/-0kGfXm4j22c/T9CtSUwUTCI/AAAAAAAAFO4/X3r2F3nt7P0/s200/SortingSmall.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2 style="text-align: left;"&gt;

&lt;span style="font-size: x-large; font-weight: normal;"&gt;Python has a lot of sorting patterns. Let's make a short a list.&lt;/span&gt;&lt;/h2&gt;
&lt;h4 style="text-align: left;"&gt;

&lt;/h4&gt;
&lt;h3 style="text-align: left;"&gt;

1. Sorting list by it's element. Simple case. Should simply do:&lt;/h3&gt;
&lt;div&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; exmpl_list &lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'a'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'c'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'B'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'d'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; exmpl_list&lt;span style="color: #808030;"&gt;.&lt;/span&gt;sort&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'a'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'B'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'c'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'d'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="font-family: inherit; text-align: left;"&gt;
&lt;span style="font-size: small;"&gt;However this example does not take locale into account and works only for ASCII characters.&lt;/span&gt;&lt;/div&gt;
&lt;h3 style="font-family: inherit; text-align: left;"&gt;

&lt;span style="font-size: small;"&gt;2. Sorting list of sub elements.&lt;/span&gt;&lt;/h3&gt;
&lt;div style="background-color: black; color: lime; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;exmpl_list &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'name'&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'Homer'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'age'&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;&lt;span style="color: #778c77;"&gt;39&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'name'&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'Bart'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'age'&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;&lt;span style="color: #778c77;"&gt;10&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;  
&lt;span style="color: #b96969;"&gt;# Sorting by 'name'  &lt;/span&gt;
newlist &lt;span style="color: #808030;"&gt;=&lt;/span&gt; sorted&lt;span style="color: #808030;"&gt;(&lt;/span&gt;exmpl_list&lt;span style="color: #808030;"&gt;,&lt;/span&gt; key&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;lambda&lt;/span&gt; k&lt;span style="color: #808030;"&gt;:&lt;/span&gt; k&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'name'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# Better way to use itemgetter():&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;from&lt;/span&gt; operator &lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; itemgetter
newlist &lt;span style="color: #808030;"&gt;=&lt;/span&gt; sorted&lt;span style="color: #808030;"&gt;(&lt;/span&gt;exmpl_list&lt;span style="color: #808030;"&gt;,&lt;/span&gt; key&lt;span style="color: #808030;"&gt;=&lt;/span&gt;itemgetter&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'name'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="font-family: Arial,Helvetica,sans-serif; text-align: left;"&gt;
&lt;span style="font-size: small;"&gt;Note that it is equivalent to:&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: black; color: lime; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;exmpl_list&lt;span style="color: #808030;"&gt;.&lt;/span&gt;sort&lt;span style="color: #808030;"&gt;(&lt;/span&gt;key&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;lambda&lt;/span&gt; k&lt;span style="color: #808030;"&gt;:&lt;/span&gt; k&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'name'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# OR:&lt;/span&gt;
exmpl_list&lt;span style="color: #808030;"&gt;.&lt;/span&gt;sort&lt;span style="color: #808030;"&gt;(&lt;/span&gt;key&lt;span style="color: #808030;"&gt;=&lt;/span&gt;itemgetter&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'name'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style="font-family: inherit; text-align: left;"&gt;
&lt;span style="font-size: small;"&gt;if you do not need new list in result.&lt;/span&gt;&lt;/div&gt;
&lt;h3 style="font-family: inherit; text-align: left;"&gt;

&lt;span style="font-size: small;"&gt;3. Local aware decision&lt;/span&gt;&lt;/h3&gt;
&lt;div class="default prettyprint" style="background-color: black; color: lime; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; locale
locale&lt;span style="color: #808030;"&gt;.&lt;/span&gt;setlocale&lt;span style="color: #808030;"&gt;(&lt;/span&gt;locale&lt;span style="color: #808030;"&gt;.&lt;/span&gt;LC_ALL&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;'en_US.UTF-8'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: #b96969;"&gt;# vary depending on your lang/locale&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;assert&lt;/span&gt; sorted&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'Ab'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'ad'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'aa'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;cmp&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;locale&lt;span style="color: #808030;"&gt;.&lt;/span&gt;strcoll&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'aa'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'Ab'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'ad'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;

&lt;span style="color: #b96969;"&gt;# Without using locale.strcoll you get:&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;assert&lt;/span&gt; sorted&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'Ab'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'ad'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'aa'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt; &lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'Ab'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'aa'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'ad'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;

4. Sorting list of tuples/lists by known element position:&lt;/h3&gt;
&lt;div style="background-color: black; color: lime; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;data &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;3&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #778c77;"&gt;4&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;5&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;6&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #778c77;"&gt;7&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;8&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;9&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt; 
data &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;2&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;3&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #778c77;"&gt;4&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;5&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;6&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #778c77;"&gt;7&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;8&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: #778c77;"&gt;9&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
 
sorted_by_second &lt;span style="color: #808030;"&gt;=&lt;/span&gt; sorted&lt;span style="color: #808030;"&gt;(&lt;/span&gt;data&lt;span style="color: #808030;"&gt;,&lt;/span&gt; key&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;lambda&lt;/span&gt; tup&lt;span style="color: #808030;"&gt;:&lt;/span&gt; tup&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
data&lt;span style="color: #808030;"&gt;.&lt;/span&gt;sort&lt;span style="color: #808030;"&gt;(&lt;/span&gt;key&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;lambda&lt;/span&gt; tup&lt;span style="color: #808030;"&gt;:&lt;/span&gt; tup&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;  &lt;span style="color: #b96969;"&gt;# sorts in place&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
BTW. &lt;span style="font-size: x-large;"&gt;&lt;a href="http://wiki.python.org/moin/HowTo/Sorting" target="_blank"&gt;Python How To: Sorting&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/iLmvqqbY83M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/3813237032343002854/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/06/python-sort-patterns.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/3813237032343002854?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/3813237032343002854?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/iLmvqqbY83M/python-sort-patterns.html" title="Python sort() patterns" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-0kGfXm4j22c/T9CtSUwUTCI/AAAAAAAAFO4/X3r2F3nt7P0/s72-c/SortingSmall.jpg" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/06/python-sort-patterns.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0IAQHY5eyp7ImA9WhVbGUU.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-1375737049549804645</id><published>2012-06-06T08:12:00.000+03:00</published><updated>2012-06-06T15:25:41.823+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-06T15:25:41.823+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="constructor" /><category scheme="http://www.blogger.com/atom/ns#" term="super" /><category scheme="http://www.blogger.com/atom/ns#" term="HttpResponse" /><category scheme="http://www.blogger.com/atom/ns#" term="inheritance" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="class" /><category scheme="http://www.blogger.com/atom/ns#" term="response" /><category scheme="http://www.blogger.com/atom/ns#" term="object" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="method" /><category scheme="http://www.blogger.com/atom/ns#" term="__init__" /><title>Python super() method and class inheritance</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-nt_axb0ZdIw/T89LEr3oVDI/AAAAAAAAFOs/HxeA2rIlhjg/s1600/MultipleInheritance1-300x287.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="191" src="http://3.bp.blogspot.com/-nt_axb0ZdIw/T89LEr3oVDI/AAAAAAAAFOs/HxeA2rIlhjg/s200/MultipleInheritance1-300x287.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
There is one more useful method in python. &lt;b&gt;super()&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; It helps to handle inheritance of ancestor class. This sounds a bit of messy. So I'll try to explain. &lt;br /&gt;
&lt;br /&gt;
You have &lt;b&gt;class A &lt;/b&gt;that does some useful things. And you have to use this &lt;b&gt;class A&lt;/b&gt; everywhere in your application with adding some piece of functionality. You may inherit this &lt;b&gt;class B(A)&lt;/b&gt; and expand it's functionality. Now you can use &lt;b&gt;class B&lt;/b&gt; in&lt;b&gt;&lt;/b&gt;stead of &lt;b&gt;class A&lt;/b&gt; everywhere and get rid of redundant operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #b96969;"&gt;# Main class (parent)&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; A&lt;span style="color: #808030;"&gt;(&lt;/span&gt;object&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;print&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'class A constructor'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #b96969;"&gt;# Main class ancestor (inheriting main class)&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; B&lt;span style="color: #808030;"&gt;(&lt;/span&gt;A&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;print&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'class B constructor'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #e34adc;"&gt;super&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;B&lt;span style="color: #808030;"&gt;,&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; For live example:&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; NOTE! Code is theoretical for you because it is taken from live project. I'm using many own written methods here. Neither &lt;b&gt;document&lt;/b&gt;&amp;nbsp;not it's methods are not django standard and given here to get the point of it all in real world&amp;nbsp;example.&lt;/i&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; You have Django &lt;b&gt;HttpResponse()&lt;/b&gt; object. Your Django application creates (instantiates) this special &lt;b&gt;HttpResponse()&lt;/b&gt; object and afterwards populates some file into it. you may often do redundancy in your code. One way: you can create a manager to instantiate &lt;b&gt;HttpResponse()&lt;/b&gt; object from scratch and then populate it with your data. But it's making your code use some additional function that instantiates and then operates object. Better (proper from python perspective) to inherit &lt;b&gt;HttpResponse()&lt;/b&gt; object and create your own, say &lt;b&gt;DocumentResponse()&lt;/b&gt; object that will be in fact standard &lt;b&gt;HttpResponse()&lt;/b&gt; that will populate itself with required data from your provided object. This will lead to code simplification. &lt;br /&gt;
&amp;nbsp; &amp;nbsp; Let's provide some code for this object's declaration:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #b96969;"&gt;# Using DJango internal object&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;from&lt;/span&gt; django&lt;span style="color: #808030;"&gt;.&lt;/span&gt;http &lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; HttpResponse

&lt;span style="color: #b96969;"&gt;# Inheriting it and populating with our data.&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; DocumentResponse&lt;span style="color: #808030;"&gt;(&lt;/span&gt;HttpResponse&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HttpResponse() object containing file.&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"""&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;,&lt;/span&gt; document&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# our redundant actions we want to get rid...&lt;/span&gt;
        content &lt;span style="color: #808030;"&gt;=&lt;/span&gt; document&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get_file_object&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        mimetype &lt;span style="color: #808030;"&gt;=&lt;/span&gt; document&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get_mimetype&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        filename &lt;span style="color: #808030;"&gt;=&lt;/span&gt; document&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get_full_filename&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# Instantiating ancestor class HttpResponse()&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# with our special parameters.&lt;/span&gt;
        &lt;span style="color: #e34adc;"&gt;super&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;DocumentResponse&lt;span style="color: #808030;"&gt;,&lt;/span&gt; self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;content&lt;span style="color: #808030;"&gt;=&lt;/span&gt;content&lt;span style="color: #808030;"&gt;,&lt;/span&gt; mimetype&lt;span style="color: #808030;"&gt;=&lt;/span&gt;mimetype&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# Making some actions with "self" like a new ancestor class instance&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# now: self == HttpResponse() &lt;/span&gt;
        self&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"Content-Length"&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt; &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;len&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;content&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
TADA! We have ability now to create our custom &lt;b&gt;HttpResponse()&lt;/b&gt; from internal file object (&lt;b&gt;document&lt;/b&gt;) everywhere in our imaginary project.&lt;br /&gt;
we can now write something like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;response &lt;span style="color: #808030;"&gt;=&lt;/span&gt; DocumentResponse&lt;span style="color: #808030;"&gt;(&lt;/span&gt;document&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
and it will provide a proper &lt;b&gt;HttpResponse()&lt;/b&gt;&amp;nbsp;object specially transformed for our needs. Django likes it and returns properly instead of &lt;b&gt;HttpResponse()&lt;/b&gt;. It has all of it's methods after all :).&lt;br /&gt;
&amp;nbsp; &amp;nbsp; One more thing to note that python will not run constructor of ancestor here until we will tell him to do it with our &lt;b&gt;super()&lt;/b&gt; method. And afterwards we can modify it too.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Naming this method may sound syntactically "to heavy". This problem is spolved in python 3.0. However there is old implementation, sometimes called &lt;i&gt;'old school'&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-color: #001800; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #b96969;"&gt;# Parrent&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; A&lt;span style="color: #808030;"&gt;(&lt;/span&gt;object&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;print&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'class A constructor'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;

&lt;span style="color: #b96969;"&gt;# Ancestor&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; B&lt;span style="color: #808030;"&gt;(&lt;/span&gt;A&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; &lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;print&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;u'class B constructor'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        A&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__init__&lt;/span&gt;&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Helped? Improper? Please leave a comment below...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/UCYqtML1TWk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/1375737049549804645/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/06/python-super-method-and-class.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1375737049549804645?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1375737049549804645?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/UCYqtML1TWk/python-super-method-and-class.html" title="Python super() method and class inheritance" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-nt_axb0ZdIw/T89LEr3oVDI/AAAAAAAAFOs/HxeA2rIlhjg/s72-c/MultipleInheritance1-300x287.jpg" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/06/python-super-method-and-class.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkAARHs_fSp7ImA9WhVXFUs.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-2363669433333234190</id><published>2012-04-16T11:25:00.000+03:00</published><updated>2012-04-16T11:25:45.545+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-16T11:25:45.545+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="tags" /><category scheme="http://www.blogger.com/atom/ns#" term="templatetag" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="characters" /><category scheme="http://www.blogger.com/atom/ns#" term="tag" /><category scheme="http://www.blogger.com/atom/ns#" term="assignment_tag" /><category scheme="http://www.blogger.com/atom/ns#" term="1.4" /><category scheme="http://www.blogger.com/atom/ns#" term="template" /><category scheme="http://www.blogger.com/atom/ns#" term="templates" /><category scheme="http://www.blogger.com/atom/ns#" term="translation" /><category scheme="http://www.blogger.com/atom/ns#" term="simpletag" /><category scheme="http://www.blogger.com/atom/ns#" term="static" /><category scheme="http://www.blogger.com/atom/ns#" term="truncate" /><category scheme="http://www.blogger.com/atom/ns#" term="new" /><category scheme="http://www.blogger.com/atom/ns#" term="templatetags" /><category scheme="http://www.blogger.com/atom/ns#" term="storage" /><category scheme="http://www.blogger.com/atom/ns#" term="staticfiles" /><title>Templates. New in Django 1.4</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-gYKCCdkOJqk/T3MLO-v7ndI/AAAAAAAAEuM/K6hUoEj6XTo/s1600/django_tp.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/-gYKCCdkOJqk/T3MLO-v7ndI/AAAAAAAAEuM/K6hUoEj6XTo/s200/django_tp.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
Continuing those series of tasty features in Django 1.4. It's templates and newly added templatetags this time. Many things&amp;nbsp;improved&amp;nbsp;in template logic now. Lets move on point by point...&lt;br /&gt;
&lt;h4&gt;
Tag&amp;nbsp;&lt;i&gt;{% elif %}&lt;/i&gt;&lt;/h4&gt;
For most of us it is almost killer feature of new Django 1.4. You will have simpler logic in your templates, if you have advanced logic there, of&amp;nbsp;course. ;)&lt;br /&gt;
&lt;h4&gt;
Key-value arguments for user tags&lt;/h4&gt;
You can use key-value for tags along with old, positional, arguments, e.g.:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; custom_tag &lt;span style="color: #778c77;"&gt;123&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;"test"&lt;/span&gt; thing&lt;span style="color: #808030;"&gt;.&lt;/span&gt;var text&lt;span style="color: #808030;"&gt;=&lt;/span&gt;msg&lt;span style="color: #808030;"&gt;|&lt;/span&gt;upper username&lt;span style="color: #808030;"&gt;=&lt;/span&gt;user&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get_full_name &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
All of this implemented using common "args" and "kwargs":&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;@register&lt;span style="color: #808030;"&gt;.&lt;/span&gt;simple_tag
&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; custom_tag&lt;span style="color: #808030;"&gt;(&lt;/span&gt;a&lt;span style="color: #808030;"&gt;,&lt;/span&gt; b&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;*&lt;/span&gt;args&lt;span style="color: #808030;"&gt;,&lt;/span&gt; &lt;span style="color: #808030;"&gt;*&lt;/span&gt;&lt;span style="color: #808030;"&gt;*&lt;/span&gt;kwargs&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    warning &lt;span style="color: #808030;"&gt;=&lt;/span&gt; kwargs&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'text'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
    profile &lt;span style="color: #808030;"&gt;=&lt;/span&gt; kwargs&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'username'&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;
&lt;i&gt;assignment_tag&lt;/i&gt;&lt;/h4&gt;
Some tags are not built to output something in template, like simple_tag. They only have to change something in context during rendering of templates. (Built-in&amp;nbsp;{% with %} tag, for e.g.). &lt;br /&gt;
You can make it output time like so:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; get_common_time &lt;span style="color: #cc5555;"&gt;"%Y-%m-%d %I:%M %p"&lt;/span&gt; as object_time &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;
The time &lt;span style="color: #508050; font-weight: bold;"&gt;is&lt;/span&gt; &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt; object_time &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
SO now you can use&amp;nbsp;&lt;i&gt;"assignment_tag"&lt;/i&gt;, to make creating tags like this simpler:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;@register&lt;span style="color: #808030;"&gt;.&lt;/span&gt;assignment_tag
&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; get_common_time&lt;span style="color: #808030;"&gt;(&lt;/span&gt;time_format&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;return&lt;/span&gt; datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;datetime&lt;span style="color: #808030;"&gt;.&lt;/span&gt;now&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;strftime&lt;span style="color: #808030;"&gt;(&lt;/span&gt;time_format&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Translation marks in context&lt;/h4&gt;
Django 1.3 appeared to have functions pgettext() and ngettext() to indicate context for translatable strings. It solved problem of short text phrases partially. It suited phrases that can have different translation depending on context. Now you can&amp;nbsp;transfer&amp;nbsp;it in&amp;nbsp;template&amp;nbsp;directly:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; trans &lt;span style="color: #cc5555;"&gt;"Iurii"&lt;/span&gt; context &lt;span style="color: #cc5555;"&gt;"username"&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;
&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; trans &lt;span style="color: #cc5555;"&gt;"Do"&lt;/span&gt; context &lt;span style="color: #cc5555;"&gt;"verb"&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;
&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; blocktrans with name&lt;span style="color: #808030;"&gt;=&lt;/span&gt;user&lt;span style="color: #808030;"&gt;.&lt;/span&gt;username context &lt;span style="color: #cc5555;"&gt;"hello message"&lt;/span&gt; &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;Hi &lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt; name &lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; endblocktrans &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;h4&gt;
New&amp;nbsp;&lt;i&gt;{% static %}&lt;/i&gt;&amp;nbsp;tag&lt;/h4&gt;
You can now share&amp;nbsp;&lt;i&gt;STATICFILES_STORAGE&lt;/i&gt;&amp;nbsp;with special tag:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: #808030;"&gt;%&lt;/span&gt; load static &lt;span style="color: #508050; font-weight: bold;"&gt;from&lt;/span&gt; staticfiles &lt;span style="color: #808030;"&gt;%&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;
&lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;img src&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"{% static "&lt;/span&gt;app&lt;span style="color: #808030;"&gt;/&lt;/span&gt;css&lt;span style="color: #808030;"&gt;/&lt;/span&gt;base&lt;span style="color: #808030;"&gt;.&lt;/span&gt;css&lt;span style="color: #cc5555;"&gt;" %}"&lt;/span&gt; &lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Most profit will get those one's that for e.g. use CDN on S3, or another not "standart" way.&amp;nbsp;&lt;i&gt;{{STATIC_URL}}&lt;/i&gt;&amp;nbsp;is equivalent to&amp;nbsp;&lt;i&gt;{% static %}&lt;/i&gt;&amp;nbsp;in other cases.&lt;br /&gt;
&lt;br /&gt;
You also get&amp;nbsp;new&amp;nbsp;&lt;i&gt;storage.CachedStaticFilesStorage,&lt;/i&gt;&amp;nbsp;that can add md5-hash to filenames from static, to make&amp;nbsp;cash for css, js, images and so on&amp;nbsp;definitely&amp;nbsp;invalid.&lt;br /&gt;
&lt;h4&gt;
&lt;i&gt;|truncatechars&lt;/i&gt;&amp;nbsp;filter&lt;/h4&gt;
Incredible but true. After 4,5 years of Django dev you received&lt;i&gt;&amp;nbsp;&lt;b&gt;|truncatechars&lt;/b&gt;&lt;/i&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;in default filers list. It can trim string to provided amount of characters and&amp;nbsp;&amp;nbsp;change the end of it into three dots... Anyway&amp;nbsp;&lt;i&gt;&lt;b&gt;|truncate_words&lt;/b&gt;&lt;/i&gt;&amp;nbsp;is also&amp;nbsp;available.&lt;br /&gt;
&lt;br /&gt;
Almost all "IMHO tasty new features in 1.4 templates" covered. The farther the more will come. Stay tuned.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/0Ly5jrmqlts" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/2363669433333234190/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/04/templates-new-in-django-14.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2363669433333234190?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2363669433333234190?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/0Ly5jrmqlts/templates-new-in-django-14.html" title="Templates. New in Django 1.4" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-gYKCCdkOJqk/T3MLO-v7ndI/AAAAAAAAEuM/K6hUoEj6XTo/s72-c/django_tp.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://garmoncheg.blogspot.com/2012/04/templates-new-in-django-14.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcMRXs4fip7ImA9WhVQEEw.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-5155313376935226224</id><published>2012-03-29T11:33:00.000+03:00</published><updated>2012-03-29T11:34:44.536+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-29T11:34:44.536+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="timezones" /><category scheme="http://www.blogger.com/atom/ns#" term="timezone" /><category scheme="http://www.blogger.com/atom/ns#" term="support" /><category scheme="http://www.blogger.com/atom/ns#" term="features" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="aware" /><category scheme="http://www.blogger.com/atom/ns#" term="new" /><category scheme="http://www.blogger.com/atom/ns#" term="datetime" /><category scheme="http://www.blogger.com/atom/ns#" term="1.4" /><category scheme="http://www.blogger.com/atom/ns#" term="release" /><category scheme="http://www.blogger.com/atom/ns#" term="date" /><category scheme="http://www.blogger.com/atom/ns#" term="UTC" /><title>Timezones. New in Django 1.4.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-SzQcfxR3r3U/T3QdwSEhx0I/AAAAAAAAEuw/B-vX3-EZPQU/s1600/django.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="160" src="http://3.bp.blogspot.com/-SzQcfxR3r3U/T3QdwSEhx0I/AAAAAAAAEuw/B-vX3-EZPQU/s320/django.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;

What and Why?&lt;/h4&gt;
Under Django version 1.4 all dates stored and displayed for a single timezone. The one that is specified in &lt;a href="https://docs.djangoproject.com/en/1.4/ref/settings/#std:setting-TIME_ZONE"&gt;project.settings.TIME_ZONE&lt;/a&gt;. Now you gain ability to store dates in &lt;a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time"&gt;UTC&lt;/a&gt; and render it with timezone correction.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://pytz.sourceforge.net/#problems-with-localtime"&gt;Problems with localtime&lt;/a&gt;&amp;nbsp;bypass is an additional plus. They can happen once a year. For e.g. 31 of November 2012 in Russia. Time from 2:00am to 3:00am in fact goes by twice. It may not be a problem for 99% of users. But it can become a nightmare for billing systems. So it's better to store time in UTC and display with user Time Zone correction. So &lt;i&gt;"02:15am 31 November 2012"&lt;/i&gt; will become&amp;nbsp;"&lt;i&gt;2012-10-30T22:15:00+04:00"&lt;/i&gt; and &lt;i&gt;"2010-10-30T23:15:00+03:00"&lt;/i&gt; that is so handy for programmers ;).&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;


Concepts&lt;/h4&gt;
&lt;i&gt;datetime&lt;/i&gt; objects in Python support timezones with attribute &lt;i&gt;tzinfo&lt;/i&gt;. If this attribute is filled out it is called "timezone-aware", otherwise it's "naive" date.&lt;br /&gt;
Django uses timezone-aware dates, if you've used new feature in Django 1.4 while update. (&lt;a href="https://docs.djangoproject.com/en/1.4/ref/settings/#std:setting-USE_TZ"&gt;settings.USE_TZ=&lt;/a&gt;True)&lt;br /&gt;
"Default timezone" in Django is the one that is specified in&amp;nbsp;&lt;a href="https://docs.djangoproject.com/en/1.4/ref/settings/#std:setting-TIME_ZONE"&gt;settings.TIME_ZONE&lt;/a&gt;. (E.g. 'Europe/Kiev'). While "current timezone" is the one that activated this moment.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;


Current timezone&lt;/h4&gt;
You need to know where is user from to show him his date and time. You can &lt;a href="https://docs.djangoproject.com/en/1.4/topics/i18n/timezones/#selecting-the-current-time-zone"&gt;ask him directly&lt;/a&gt;&amp;nbsp;and store his timezone in session BTW. You can use DB's like "maxmind", guessing his timezone by IP or even use JavaScript: &lt;i&gt;Date.getTimezoneOffset()&lt;/i&gt;. One or another way we need to activate user's timezone to get access to rendering of timezone aware date and time in templates and forms.&lt;br /&gt;
&lt;br /&gt;
Example of setting current timezone (from Django docs):&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;from&lt;/span&gt; django&lt;span style="color: #808030;"&gt;.&lt;/span&gt;utils &lt;span style="color: #508050; font-weight: bold;"&gt;import&lt;/span&gt; timezone

&lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt; TimezoneMiddleware&lt;span style="color: #808030;"&gt;(&lt;/span&gt;object&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; process_request&lt;span style="color: #808030;"&gt;(&lt;/span&gt;self&lt;span style="color: #808030;"&gt;,&lt;/span&gt; request&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        tz &lt;span style="color: #808030;"&gt;=&lt;/span&gt; request&lt;span style="color: #808030;"&gt;.&lt;/span&gt;session&lt;span style="color: #808030;"&gt;.&lt;/span&gt;get&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'django_timezone'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;if&lt;/span&gt; tz&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
            timezone&lt;span style="color: #808030;"&gt;.&lt;/span&gt;activate&lt;span style="color: #808030;"&gt;(&lt;/span&gt;tz&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Main functionality we need for this issue is concentrated in '&lt;a href="https://docs.djangoproject.com/en/1.4/ref/utils/#django-utils-timezone"&gt;django.utils.timezone&lt;/a&gt;'.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;


Templates&lt;/h4&gt;
Those dates workout is widely supported in &lt;a href="https://docs.djangoproject.com/en/1.4/topics/i18n/timezones/#timezone"&gt;templates&lt;/a&gt; along with Python code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;# Converting to Paris timezone
{% timezone &lt;span style="color: #cc5555;"&gt;"Europe/Paris"&lt;/span&gt; %}
    Paris &lt;span style="color: #508050; font-weight: bold;"&gt;time&lt;/span&gt;: {{ value }}
{% endtimezone %}

# &lt;span style="color: #508050; font-weight: bold;"&gt;default&lt;/span&gt; date display&lt;span style="color: #808030;"&gt;,&lt;/span&gt; like they&lt;span style="color: #cc5555;"&gt;'re actually stored (UTC)&lt;/span&gt;
{% localtime off %}
    {{ value }}
{% endlocaltime %}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;


Migration&lt;/h4&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Setting&amp;nbsp;&lt;i&gt;settings.USE_TZ = True&amp;nbsp;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;pip install pytz&amp;nbsp;&lt;/i&gt;(read farther)&lt;/li&gt;
&lt;li&gt;Convert DB datetime values into UTC time. (If it is different)&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
Now your code supports timezones. You have to repair some old places where Django does not handle it for us. We have to convert naive dates into timezone-aware. Otherwise you can get wired bugs while changing Winter/Somer time.&amp;nbsp;To complete the migration you have to use&amp;nbsp;'&lt;a href="https://docs.djangoproject.com/en/1.4/ref/utils/#django-utils-timezone"&gt;django.utils.timezone&lt;/a&gt;' and debug places where dates in new format are compared to "new" one's.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;


&lt;span style="font-size: medium;"&gt;pytz&lt;/span&gt;&lt;/h4&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-size: medium;"&gt;Library that handles handy timezone workout in python. &lt;a href="http://en.wikipedia.org/wiki/Tz_database"&gt;Olson&amp;nbsp;database&lt;/a&gt;&amp;nbsp;and &lt;a href="http://pytz.sourceforge.net/"&gt;handy API&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: medium;"&gt;are included for different timezone calculations&lt;/span&gt;&lt;span style="font-size: medium;"&gt;. Despite it is optional in Django 1.4 developers&amp;nbsp;recommend&amp;nbsp;to include it. It helps Framework not to guess default timezones while calculating time and provides timezone list to render for users.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;


Conclusion&lt;/h4&gt;
Those new features make me proud user of this framework and&amp;nbsp;simplify&amp;nbsp;many holes that I had to handle myself. E.g. with hosting app using&amp;nbsp;Australia/Sydney Timezone and working with it in Europe/Kiev. ;)&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/P1DZORGtqU8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/5155313376935226224/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/03/new-in-django-14-timezones.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/5155313376935226224?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/5155313376935226224?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/P1DZORGtqU8/new-in-django-14-timezones.html" title="Timezones. New in Django 1.4." /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-SzQcfxR3r3U/T3QdwSEhx0I/AAAAAAAAEuw/B-vX3-EZPQU/s72-c/django.png" height="72" width="72" /><thr:total>2</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/03/new-in-django-14-timezones.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUMR3w6fyp7ImA9WhVQEEw.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-2993348685389713259</id><published>2012-03-28T16:03:00.000+03:00</published><updated>2012-03-29T13:18:06.217+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-29T13:18:06.217+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="templatetag" /><category scheme="http://www.blogger.com/atom/ns#" term="tag" /><category scheme="http://www.blogger.com/atom/ns#" term="filter" /><category scheme="http://www.blogger.com/atom/ns#" term="form" /><category scheme="http://www.blogger.com/atom/ns#" term="name" /><category scheme="http://www.blogger.com/atom/ns#" term="approach" /><category scheme="http://www.blogger.com/atom/ns#" term="templates" /><category scheme="http://www.blogger.com/atom/ns#" term="simpletag" /><category scheme="http://www.blogger.com/atom/ns#" term="styling" /><category scheme="http://www.blogger.com/atom/ns#" term="type" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="css" /><category scheme="http://www.blogger.com/atom/ns#" term="field" /><title>Django template tags to find out field type</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-gYKCCdkOJqk/T3MLO-v7ndI/AAAAAAAAEuM/K6hUoEj6XTo/s1600/django_tp.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-gYKCCdkOJqk/T3MLO-v7ndI/AAAAAAAAEuM/K6hUoEj6XTo/s1600/django_tp.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: inherit;"&gt;Sometimes you have the task to decorate django form fields. In our case it was need to add different widget to form field depending on field type.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;i&gt;You can know your field type by refering to it's python class name, e.g.:&lt;/i&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;field&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__class__&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__name__&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
You will get wrong symbols error if you try to refer this python variable in templates directly. So you need a custom template tag to serve here. Decision was not to return variable for tag but to add context variable, cause I had need to perform exact actions on certain field types.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
So tag example:&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;@register&lt;span style="color: #808030;"&gt;.&lt;/span&gt;simple_tag&lt;span style="color: #808030;"&gt;(&lt;/span&gt;takes_context&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;True&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;def&lt;/span&gt; set_this_field_type&lt;span style="color: #808030;"&gt;(&lt;/span&gt;context&lt;span style="color: #808030;"&gt;,&lt;/span&gt; field&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;"""&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Adds to context given field type variable&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;variable named "this_field_type"&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"""&lt;/span&gt;
    context&lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;"this_field_type"&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt; &lt;span style="color: #808030;"&gt;=&lt;/span&gt; field&lt;span style="color: #808030;"&gt;.&lt;/span&gt;field&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__class__&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #e34adc;"&gt;__name__&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;&lt;/pre&gt;
&lt;div style="text-align: left;"&gt;
Now you can add this variable to your if statements. E.g. usage:&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; text-align: -webkit-auto;"&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; color: #55cc66;"&gt;&lt;span style="color: #b96969;"&gt;{% load my_template_lib %}&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;{% for field in form %}&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;{# Setting this field type in context #}&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;{% set_this_field_type field %}&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;{% if not this_field_type = "DateField" %}&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;{# Rendering specific for Date fields (With DatePicker widget) #}&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt; &lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"field&lt;span style="color: #808030;"&gt;-&lt;/span&gt;wrapper &lt;span style="color: #b96969;"&gt;{{ this_field_type }&lt;/span&gt;}"
        &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt; &lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"control&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;"&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #b96969;"&gt;{{ field.label }&lt;/span&gt;}&lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;input id&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"&lt;span style="color: #b96969;"&gt;{{ field.id_for_label }&lt;/span&gt;}" &lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"datepicker&lt;span style="color: #808030;"&gt;-&lt;/span&gt;widget" &lt;span style="color: #508050; font-weight: bold;"&gt;type&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"&lt;span style="color: #bb7977;"&gt;text&lt;/span&gt;" name&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"&lt;span style="color: #b96969;"&gt;{{ field.name }&lt;/span&gt;}"&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;{% else %}&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;{# Default field rendering #}&lt;/span&gt;
    &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt; &lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"field&lt;span style="color: #808030;"&gt;-&lt;/span&gt;wrapper &lt;span style="color: #b96969;"&gt;{{ this_field_type }&lt;/span&gt;}"
         &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt; &lt;span style="color: #508050; font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;"control&lt;span style="color: #808030;"&gt;-&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;"&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #b96969;"&gt;{{ field.label }&lt;/span&gt;}&lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;label&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;{{ field }&lt;/span&gt;}
    &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;div&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;{% endif %}&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;{% endfor %}&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;div style="text-align: left;"&gt;
You will get your form fields rendered in custom manner. You will have the CSS class with field type for styling or you can use this variable in context to render various widgets for e.g.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Hope you've got the main concept here. Now this idea must be limited only by your imagination.&lt;br /&gt;
&lt;br /&gt;
Including those "simple" approaches kindly suggested by guys at 'reddit.com' They are more simple and can play in your case maybe ;)&lt;br /&gt;
Using the filter: (Thanks to &lt;a href="http://www.reddit.com/user/POTUS"&gt;POTUS&lt;/a&gt;&amp;nbsp;@reddit.com)&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;@register&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;filter()
def field_type(field):
    return field&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;field&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;__class__&lt;span style="color: #778c77;"&gt;.&lt;/span&gt;__name__

{% if not field|field_type ="DateField" %}
    &lt;span style="color: #865700;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;span&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;Whatever&lt;span style="color: #865700;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #508050; font-weight: bold;"&gt;span&lt;/span&gt;&lt;span style="color: #865700;"&gt;&amp;gt;&lt;/span&gt;
{%endif%}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Using the widget: (Thanks to&amp;nbsp;&lt;a class="author id-t2_4eohc" href="http://www.reddit.com/user/tgerdes"&gt;tgerdes&lt;/a&gt;&amp;nbsp;@reddit.com)&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;from django import forms
class DateForm(forms.Form):
    date = forms.DateField(
      widget=forms.DateInput(attrs= {'class': 'datepicker-widget' } ))

form = DateForm()
print form.as_p()&lt;/pre&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #e34adc;"&gt;outputs:&lt;/span&gt; &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;p&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;label &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;id_date&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;Date&lt;span style="color: purple;"&gt;:&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;label&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;input id&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;id_date&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; type&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;text&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; class&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;datepicker-widget&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; name&lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;date&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt; &lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;p&lt;span style="color: #808030;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
However this approach in not this topics main cause it concludes we only have to style input. But in some cases it may be quite enough...&lt;br /&gt;
&lt;br /&gt;
Thanks guys for correction!&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Please drop me a comment here if you've liked/used this decision(s).&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/5CC2abYL_Z0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/2993348685389713259/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/03/django-template-tags-to-find-out-field.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2993348685389713259?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/2993348685389713259?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/5CC2abYL_Z0/django-template-tags-to-find-out-field.html" title="Django template tags to find out field type" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-gYKCCdkOJqk/T3MLO-v7ndI/AAAAAAAAEuM/K6hUoEj6XTo/s72-c/django_tp.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://garmoncheg.blogspot.com/2012/03/django-template-tags-to-find-out-field.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkINRHs_eip7ImA9WhVTEEs.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-1414659395890721715</id><published>2012-02-24T08:20:00.000+02:00</published><updated>2012-02-24T08:23:15.542+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-24T08:23:15.542+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rm" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="find" /><category scheme="http://www.blogger.com/atom/ns#" term="controll" /><category scheme="http://www.blogger.com/atom/ns#" term="error" /><category scheme="http://www.blogger.com/atom/ns#" term="source" /><category scheme="http://www.blogger.com/atom/ns#" term="pyc" /><category scheme="http://www.blogger.com/atom/ns#" term="dejavu" /><category scheme="http://www.blogger.com/atom/ns#" term="version" /><category scheme="http://www.blogger.com/atom/ns#" term="old" /><category scheme="http://www.blogger.com/atom/ns#" term="file" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="place" /><category scheme="http://www.blogger.com/atom/ns#" term="compiler" /><category scheme="http://www.blogger.com/atom/ns#" term="recursively" /><title>Delete all '.pyc' files recursively OS X</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-qUvzPu3UJGA/T0cszE_8onI/AAAAAAAAElw/2IKGgzRwvGE/s1600/python-on-mac.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-qUvzPu3UJGA/T0cszE_8onI/AAAAAAAAElw/2IKGgzRwvGE/s1600/python-on-mac.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We often get strange errors with python. When you changing the source and cannot figure out why files are used from past. So if you ever get this dejavu feeling, try using this command:&lt;br /&gt;
&lt;div style="background-color: black; color: #6aa84f; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;
&lt;i&gt;&lt;b&gt;find . -type f -name '*.pyc' -exec rm {} \;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
It will delete all precompiled python sources. (Because with python you have ability to distribute your files in binaries in fact.) Those errors usually appear if you move/delete *.py files with version control. You usually exclude *.pyc files from list. Old links used this way. Debugger does not suggest wrong imports because your files are in fact there, just precompiled.&lt;br /&gt;
Anyway I've just put this command to my blog for memorizing. It often helps me. Maybe it can for you.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/bjtkLY3hWQ4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/1414659395890721715/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/02/delete-all-pyc-files-recursively-os-x.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1414659395890721715?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/1414659395890721715?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/bjtkLY3hWQ4/delete-all-pyc-files-recursively-os-x.html" title="Delete all '.pyc' files recursively OS X" /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-qUvzPu3UJGA/T0cszE_8onI/AAAAAAAAElw/2IKGgzRwvGE/s72-c/python-on-mac.png" height="72" width="72" /><thr:total>4</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/02/delete-all-pyc-files-recursively-os-x.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUDSHs7cSp7ImA9WhVQEEw.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-4821889378469588695</id><published>2012-01-26T12:28:00.000+02:00</published><updated>2012-03-29T12:44:39.509+03:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-29T12:44:39.509+03:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="characters" /><category scheme="http://www.blogger.com/atom/ns#" term="encoding" /><category scheme="http://www.blogger.com/atom/ns#" term="'ascii' codec can't encode character" /><category scheme="http://www.blogger.com/atom/ns#" term="error" /><category scheme="http://www.blogger.com/atom/ns#" term="ascii" /><category scheme="http://www.blogger.com/atom/ns#" term="ordinal" /><category scheme="http://www.blogger.com/atom/ns#" term="CSV" /><category scheme="http://www.blogger.com/atom/ns#" term="UnicodeEncodeError" /><category scheme="http://www.blogger.com/atom/ns#" term="unicode" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="in" /><category scheme="http://www.blogger.com/atom/ns#" term="ordinal not in range" /><category scheme="http://www.blogger.com/atom/ns#" term="ordinal not in range(128)" /><category scheme="http://www.blogger.com/atom/ns#" term="range" /><category scheme="http://www.blogger.com/atom/ns#" term="hack" /><category scheme="http://www.blogger.com/atom/ns#" term="not" /><title>Python / Django UnicodeEncodeError hacks.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-REa4IzkwD5I/TyEm-4JyM0I/AAAAAAAAEkg/KTWHX7eFNA0/s1600/unicode_icon.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://2.bp.blogspot.com/-REa4IzkwD5I/TyEm-4JyM0I/AAAAAAAAEkg/KTWHX7eFNA0/s200/unicode_icon.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
Python plays with unicode nicely&amp;nbsp;nowadays. Bt what if you must deal with old time formats conversion, or ASCII files exporting for e.g. You may also use software that is out of date but is too long to rewrite... &amp;nbsp;Here often errors occur. I have&amp;nbsp;received&amp;nbsp;mine at&amp;nbsp;copy-pasting from&amp;nbsp;MS Word&amp;nbsp;into Django admin UI&amp;nbsp;&amp;nbsp;by stupid users. Most of the website played nicely with this fancy characters, but exporting to CSV failed due to non ASCII characters&amp;nbsp;support. Google&amp;nbsp;said&amp;nbsp;nothing special. &lt;a href="http://docs.python.org/howto/unicode.html"&gt;Python docs about unicode&lt;/a&gt; usage briefly cover this type of events. So here is the result of some hours of experiments. I've decided to rewrite some of the python functionality to create decode function with&amp;nbsp;behavior&amp;nbsp;for my needs. Hopefully they will shorten you some time with those collisions you may get in your Django apps...&lt;br /&gt;
&lt;br /&gt;
Anyway I've started to&amp;nbsp;receive&amp;nbsp;errors like:&lt;br /&gt;
&lt;pre class="exception_value" style="background-color: #ffffcc; margin-bottom: 10px; margin-top: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;"&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial;"&gt;&lt;span style="color: #6aa84f;"&gt;Exception Type:  UnicodeEncodeError&lt;/span&gt;&lt;span style="color: #55cc66;"&gt;
&lt;/span&gt;&lt;span style="color: #93c47d;"&gt;Exception Value: 'ascii' codec can't encode character u'&lt;span style="font-weight: bold;"&gt;\u&lt;/span&gt;2013' in position 17: ordinal not in range(128)&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
So I had a &lt;b&gt;list&lt;/b&gt; of &lt;b&gt;u''&lt;/b&gt; values that contained special characters "&amp;nbsp;&lt;b&gt;ordinal not in range(128) &lt;/b&gt;". Requires no imports... Pure python:&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; text-align: -webkit-auto;"&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; color: #55cc66;"&gt;        values &lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;
          &lt;span style="color: #cc5555;"&gt;u'Some fancy text \u2013 something'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
          &lt;span style="color: #cc5555;"&gt;u'some normal, easy convertible text'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
          &lt;span style="color: #cc5555;"&gt;u'some more normal text'&lt;/span&gt;
          &lt;span style="color: #808030;"&gt;]&lt;/span&gt;      
        HACK&lt;span style="color: #808030;"&gt;:&lt;/span&gt; entry cleanup &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; special characters &lt;span style="color: #808030;"&gt;(&lt;/span&gt;Fixing Bug &lt;span style="color: #b96969;"&gt;#...)&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# entry cleanup for special characters&lt;/span&gt;
        i &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #778c77;"&gt;0&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; value &lt;span style="color: #508050; font-weight: bold;"&gt;in&lt;/span&gt; values&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
            &lt;span style="color: #508050; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
                &lt;span style="color: #b96969;"&gt;# if string can be encoded to 'ascii' pass&lt;/span&gt;
                unicode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;value&lt;span style="color: #808030;"&gt;)&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;encode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'ascii'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
            &lt;span style="color: #508050; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span style="color: #808030;"&gt; UnicideEncodeError:&lt;/span&gt;
                val_temp &lt;span style="color: #808030;"&gt;=&lt;/span&gt; unicode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;value&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
                &lt;span style="color: #b96969;"&gt;# cleaning up string with escaping non convertible characters&lt;/span&gt;
                result &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
                &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; symbol &lt;span style="color: #508050; font-weight: bold;"&gt;in&lt;/span&gt; val_temp&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
                    &lt;span style="color: #508050; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
                        symbol&lt;span style="color: #808030;"&gt;.&lt;/span&gt;encode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'ascii'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
                        result&lt;span style="color: #808030;"&gt;.&lt;/span&gt;append&lt;span style="color: #808030;"&gt;(&lt;/span&gt;symbol&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
                    &lt;span style="color: #508050; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span style="color: #808030;"&gt; UnicodeEncodeError:&lt;/span&gt;
                        &lt;span style="color: #508050; font-weight: bold;"&gt;pass&lt;/span&gt;
                &lt;span style="color: #b96969;"&gt;# rewriting wrong value in values array&lt;/span&gt;
                val_temp &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;join&lt;span style="color: #808030;"&gt;(&lt;/span&gt;result&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
                values&lt;span style="color: #808030;"&gt;[&lt;/span&gt;i&lt;span style="color: #808030;"&gt;]&lt;/span&gt; &lt;span style="color: #808030;"&gt;=&lt;/span&gt; val_temp
                &lt;span style="color: #508050; font-weight: bold;"&gt;pass&lt;/span&gt;
            i &lt;span style="color: #808030;"&gt;=&lt;/span&gt; i&lt;span style="color: #808030;"&gt;+&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;
        &lt;span style="color: #b96969;"&gt;# normally work with our list... it's safe now...&lt;/span&gt;
        values &lt;span style="color: #808030;"&gt;=&lt;/span&gt;&lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;
          &lt;span style="color: #cc5555;"&gt;u'Some fancy text  something'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
          &lt;span style="color: #cc5555;"&gt;u'some normal, easy convertible text'&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt; 
          &lt;span style="color: #cc5555;"&gt;u'some more normal text'&lt;/span&gt;
          &lt;span style="color: #808030;"&gt;]&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
This code is a bit complicated due to mine specific task and has iterations in iterations etc... But it's from a working app and checked working. However here is the theoretical example that must clean up a single string:&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; text-align: -webkit-auto;"&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; color: #55cc66;"&gt;&lt;pre style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial;"&gt;value &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'Some fancy text \u2013 something'&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# if string can be encoded to 'ascii' pass&lt;/span&gt;
    value&lt;span style="color: #808030;"&gt;.&lt;/span&gt;encode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'ascii'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
&lt;span style="color: #508050; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# cleaning up string with escaping non convertible characters&lt;/span&gt;
    result &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #808030;"&gt;[&lt;/span&gt;&lt;span style="color: #808030;"&gt;]&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;for&lt;/span&gt; symbol &lt;span style="color: #508050; font-weight: bold;"&gt;in&lt;/span&gt; val_temp&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;try&lt;/span&gt;&lt;span style="color: #808030;"&gt;:&lt;/span&gt;
            symbol&lt;span style="color: #808030;"&gt;.&lt;/span&gt;encode&lt;span style="color: #808030;"&gt;(&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;'ascii'&lt;/span&gt;&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
            result&lt;span style="color: #808030;"&gt;.&lt;/span&gt;append&lt;span style="color: #808030;"&gt;(&lt;/span&gt;symbol&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
        &lt;span style="color: #508050; font-weight: bold;"&gt;except&lt;/span&gt;&lt;span style="color: #808030;"&gt; UnicodeEncodeError:&lt;/span&gt;
            &lt;span style="color: #508050; font-weight: bold;"&gt;pass&lt;/span&gt;
    &lt;span style="color: #b96969;"&gt;# rewriting our variable with safe one&lt;/span&gt;
    value &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;''&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;join&lt;span style="color: #808030;"&gt;(&lt;/span&gt;result&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
    &lt;span style="color: #508050; font-weight: bold;"&gt;pass&lt;/span&gt;
&lt;span style="color: #b96969;"&gt;# normally work with our unicode string... it's safe now...&lt;/span&gt;
value &lt;span style="color: #808030;"&gt;=&lt;/span&gt; &lt;span style="color: #cc5555;"&gt;u'Some fancy text  something&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;/pre&gt;
So the&amp;nbsp;technique&amp;nbsp;here is simple. We are checking if this unicode string can be converted to 'ascii' python encoding without errors we simply passing through. And if it's not... Converting it to 'ascii' string symbol by symbol. Symbols that will fail will be gracefully omitted. You can create a function from all of this, like 'my_decode_cleanup' or something and use whenever needed...&lt;br /&gt;
&lt;br /&gt;
Hope this will help you to save some precious time during your python development.&lt;br /&gt;
&lt;br /&gt;
Helped? I'm wrong somewhere? Please comment!&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/NHOFKjmvw1A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/4821889378469588695/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/01/python-django-unicodeencodeerror-hacks.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4821889378469588695?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/4821889378469588695?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/NHOFKjmvw1A/python-django-unicodeencodeerror-hacks.html" title="Python / Django UnicodeEncodeError hacks." /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-REa4IzkwD5I/TyEm-4JyM0I/AAAAAAAAEkg/KTWHX7eFNA0/s72-c/unicode_icon.jpg" height="72" width="72" /><thr:total>3</thr:total><georss:featurename>Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.707045 25.246419 50.787421 25.404346999999998</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/01/python-django-unicodeencodeerror-hacks.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEAFRXY5eyp7ImA9WhRVF00.&quot;"><id>tag:blogger.com,1999:blog-8227451082901531762.post-6587486484167552909</id><published>2012-01-16T11:38:00.001+02:00</published><updated>2012-01-16T11:38:34.823+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-16T11:38:34.823+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="server" /><category scheme="http://www.blogger.com/atom/ns#" term="ports" /><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="OSX" /><category scheme="http://www.blogger.com/atom/ns#" term="bug" /><category scheme="http://www.blogger.com/atom/ns#" term="error" /><category scheme="http://www.blogger.com/atom/ns#" term="installing" /><category scheme="http://www.blogger.com/atom/ns#" term="CouchDB" /><category scheme="http://www.blogger.com/atom/ns#" term="DB" /><category scheme="http://www.blogger.com/atom/ns#" term="bugs" /><category scheme="http://www.blogger.com/atom/ns#" term="install" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="mac" /><category scheme="http://www.blogger.com/atom/ns#" term="manual" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><category scheme="http://www.blogger.com/atom/ns#" term="browser" /><title>Installing CouchDB for Mac OS X. Nuances.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-LV7a8UmEghw/TspCkAaLuUI/AAAAAAAAEi0/KthXC6wgUEk/s1600/292331-os-x-lion.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/-LV7a8UmEghw/TspCkAaLuUI/AAAAAAAAEi0/KthXC6wgUEk/s200/292331-os-x-lion.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a href="http://4.bp.blogspot.com/-Y27tjnq3BLw/TxPvSHvtMPI/AAAAAAAAEkM/timXKQrA-ks/s1600/couchDB.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="150" src="http://4.bp.blogspot.com/-Y27tjnq3BLw/TxPvSHvtMPI/AAAAAAAAEkM/timXKQrA-ks/s200/couchDB.png" width="200" /&gt;&lt;/a&gt;Our project will have a new architecture changes in future. We've chosen from different tech. But now we 're experimenting with CouchDB a bit. It may become a part of our new architectural Changes. I'll try to cover most of newbies&amp;nbsp;observations&amp;nbsp;with CouchDB for Python(Django) programmer, planning to use it in your project.&lt;br /&gt;
&lt;br /&gt;
First article will be, unsurprisingly, installing CouchDB under Mac OS X. It, sure, has some inches that you need to scratch. So let's roll...&lt;br /&gt;
&lt;br /&gt;
CouchDB is not a simple SQL database like you used to install before. It has own server to accept connections. And, in fact, you can work with database from your browser GUI (without other server proxy, like Django or ...). Anyway it will not be our target. Building JS UI is quite easier with CouchDB and changes your logic&amp;nbsp;dramatically. To&amp;nbsp;build&amp;nbsp;UI with Python we need some proxy parts. Anyway, again, CouchDB is a standalone server, that runs on your server's port and talks to your APP/Browser/whatever... through JSON API. It's quite a bad thing, because it's a bit slow, but a good thing, because it's&amp;nbsp;extremely&amp;nbsp;easy to implement. Most programming languages have adaptors to JSON. &amp;nbsp;CouchDB is quite a new tech. And it is highly developed and "pushed through" tech for now...&lt;br /&gt;
&lt;br /&gt;
Ok enough preface...&amp;nbsp;Actual&amp;nbsp;install is described in official &lt;a href="http://wiki.apache.org/couchdb/Installing_on_OSX"&gt;DOCS HERE&lt;/a&gt;. I'm using "mac ports" for my project already. So it's my choice of install method by all means. I'll cover docs here in brief to be consistent:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Install it through mac ports.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ sudo port install couchdb&lt;/pre&gt;
&lt;br /&gt;
Will start&amp;nbsp;huge&amp;nbsp;and massive install of required ports for this DB. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2.&lt;/b&gt; Good idea would be to &lt;b&gt;update Mac ports&lt;/b&gt;. If you have some ports installed&amp;nbsp;already, like I do:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ sudo port upgrade couchdb&lt;/pre&gt;
&lt;br /&gt;
Will upgrade only ports required by "couchdb" port.&lt;br /&gt;
It's also a good idea to selfupdate ports if you already have them installed:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ sudo port selfupdate&lt;/pre&gt;
&lt;br /&gt;
This must be sufficient for all of our needs.&lt;br /&gt;
&lt;br /&gt;
At this point you must be able to run CouchDB from command line running:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ couchdb&lt;/pre&gt;
&lt;br /&gt;
command in Terminal. If it runs with error, no worries. Read on. There is a known issue!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. &amp;nbsp;Bug occurs in MacPorts&lt;/b&gt; itself with "couchdb" package. It does not create some&amp;nbsp;paths&amp;nbsp;in required dir. You need to manually create those paths and give CouchDB permissions to write there. &lt;a href="https://trac.macports.org/ticket/32102"&gt;Mac Ports Track&lt;/a&gt; has the solution. Or you can manually (better IMHO) make sure all your permissions and directories exist.&lt;br /&gt;
You need to make sure those directories exist, and create them if they don't:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;var&lt;span style="color: #808030;"&gt;/&lt;/span&gt;lib&lt;span style="color: #808030;"&gt;/&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;/&lt;/span&gt;
&lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;var&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #603000;"&gt;log&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;/&lt;/span&gt;
&lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;etc&lt;span style="color: #808030;"&gt;/&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
and have permission to work with CouchDB:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ sudo chown &lt;span style="color: #808030;"&gt;-&lt;/span&gt;R couchdb&lt;span style="color: purple;"&gt;:&lt;/span&gt;couchdb &lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;var&lt;span style="color: #808030;"&gt;/&lt;/span&gt;lib&lt;span style="color: #808030;"&gt;/&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;/&lt;/span&gt;
$ sudo chown &lt;span style="color: #808030;"&gt;-&lt;/span&gt;R couchdb&lt;span style="color: purple;"&gt;:&lt;/span&gt;couchdb &lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;var&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;span style="color: #603000;"&gt;log&lt;/span&gt;&lt;span style="color: #808030;"&gt;/&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;/&lt;/span&gt;
$ sudo chown &lt;span style="color: #808030;"&gt;-&lt;/span&gt;R couchdb&lt;span style="color: purple;"&gt;:&lt;/span&gt;couchdb &lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;etc&lt;span style="color: #808030;"&gt;/&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;/&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
(Those paths are ok for a standart "mac ports" install.. If your directories differ... than change those paths accordingly)&lt;br /&gt;
After those actions,&amp;nbsp;running&amp;nbsp;couchdb from console should led to normal startup sequence output:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ couchdb
Apache CouchDB &lt;span style="color: #778c77;"&gt;1.1&lt;/span&gt;&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;span style="color: #778c77;"&gt;1&lt;/span&gt;&lt;span style="color: #808030;"&gt;-&lt;/span&gt;incubating &lt;span style="color: #808030;"&gt;(&lt;/span&gt;LogLevel&lt;span style="color: #808030;"&gt;=&lt;/span&gt;info&lt;span style="color: #808030;"&gt;)&lt;/span&gt;
Apache CouchDB is starting&lt;span style="color: #808030;"&gt;.&lt;/span&gt;
Apache CouchDB has started&lt;span style="color: #808030;"&gt;.&lt;/span&gt; Time to relax&lt;span style="color: #808030;"&gt;.&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
This will signal that your CouchDB install is almost OK and you may check that it is running:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #e34adc;"&gt;http:&lt;/span&gt;&lt;span style="color: #b96969;"&gt;//127.0.0.1:5984/&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
In your browser. It must Show output JSON. Something like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: purple;"&gt;{&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;couchdb&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: purple;"&gt;:&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;Welcome&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #808030;"&gt;,&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;version&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: purple;"&gt;:&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: #cc5555;"&gt;1.1.1&lt;/span&gt;&lt;span style="color: maroon;"&gt;"&lt;/span&gt;&lt;span style="color: purple;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
You may also examine it's web admin UI, typing in browser:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;&lt;span style="color: #e34adc;"&gt;http:&lt;/span&gt;&lt;span style="color: #b96969;"&gt;//127.0.0.1:5984/_utils/index.html&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Should show handy Admin UI. You may examine/edit DB by hand there... (Something similar to PHP MyAdmin or whatever you used to use on SQL DB's)&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-y_NvO6EbtWU/TxPvxREltmI/AAAAAAAAEkU/e1j5hMU4IGc/s1600/Screen+Shot+2012-01-16+at+11.36.42+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://2.bp.blogspot.com/-y_NvO6EbtWU/TxPvxREltmI/AAAAAAAAEkU/e1j5hMU4IGc/s640/Screen+Shot+2012-01-16+at+11.36.42+AM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;4. Add autorun command (optionally).&lt;/b&gt; It's good to run every time you need it for experiments, etc... But if you plan to Debug test apps on that platform it's good idea to make it start with system every toime it runs. To make that you need to type this command into console:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style="background-attachment: initial; background-clip: initial; background-color: #001800; background-image: initial; background-origin: initial; color: #55cc66; text-align: -webkit-auto;"&gt;$ sudo launchctl load &lt;span style="color: #808030;"&gt;-&lt;/span&gt;w &lt;span style="color: #808030;"&gt;/&lt;/span&gt;opt&lt;span style="color: #808030;"&gt;/&lt;/span&gt;local&lt;span style="color: #808030;"&gt;/&lt;/span&gt;Library&lt;span style="color: #808030;"&gt;/&lt;/span&gt;LaunchDaemons&lt;span style="color: #808030;"&gt;/&lt;/span&gt;org&lt;span style="color: #808030;"&gt;.&lt;/span&gt;apache&lt;span style="color: #808030;"&gt;.&lt;/span&gt;couchdb&lt;span style="color: #808030;"&gt;.&lt;/span&gt;plist&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
THE END.&lt;br /&gt;
&lt;br /&gt;
Comments and suggestions are welcome!&lt;br /&gt;
In future I plan to make some articles on actual&amp;nbsp;befriending&amp;nbsp;CouchDB with Python. Stay tuned and thanks for reading that far.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/WebProgrammerBlog/~4/Dv3fibNoKlY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://garmoncheg.blogspot.com/feeds/6587486484167552909/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://garmoncheg.blogspot.com/2012/01/installing-couchdb-for-mac-os-x-nuances.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/6587486484167552909?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8227451082901531762/posts/default/6587486484167552909?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/WebProgrammerBlog/~3/Dv3fibNoKlY/installing-couchdb-for-mac-os-x-nuances.html" title="Installing CouchDB for Mac OS X. Nuances." /><author><name>Iurii Garmash</name><uri>https://plus.google.com/114725855189900511727</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vyCEa7hw-jU/AAAAAAAAAAI/AAAAAAAAFgI/Y0kmiyhsx1g/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-LV7a8UmEghw/TspCkAaLuUI/AAAAAAAAEi0/KthXC6wgUEk/s72-c/292331-os-x-lion.jpg" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Voli Ave, 2, Luts&amp;#39;k, Volyns&amp;#39;ka oblast, Ukraine, 43000</georss:featurename><georss:point>50.747233 25.325383</georss:point><georss:box>50.5861345 25.009525999999997 50.9083315 25.64124</georss:box><feedburner:origLink>http://garmoncheg.blogspot.com/2012/01/installing-couchdb-for-mac-os-x-nuances.html</feedburner:origLink></entry></feed>
