<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tivix Blog</title>
	<atom:link href="http://blog.tivix.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tivix.com</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 08:10:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Getting Django working with MSSQL / pyodbc</title>
		<link>http://blog.tivix.com/2012/02/08/getting-django-working-with-mssql-pyodbc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-django-working-with-mssql-pyodbc</link>
		<comments>http://blog.tivix.com/2012/02/08/getting-django-working-with-mssql-pyodbc/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 07:45:45 +0000</pubDate>
		<dc:creator>Dariusz Fryta</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[legacy]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[odbc]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pyodbc]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[windows MSSQL]]></category>

		<guid isPermaLink="false">http://blog.tivix.com/?p=1977</guid>
		<description><![CDATA[Some projects require a MSSQL database (either legacy or for other reasons). Unfortunately Django doesn&#8217;t officially support this database (yet). In this tutorial we will show how to connect to MSSQL from Python/Django using pyodbc. Installing on Mac OS X First &#8230; <a href="http://blog.tivix.com/2012/02/08/getting-django-working-with-mssql-pyodbc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some projects require a MSSQL database (either legacy or for other reasons). Unfortunately Django doesn&#8217;t officially support this database (yet).</p>
<p>In this tutorial we will show how to connect to MSSQL from Python/Django using pyodbc.</p>
<h3 style="color:#E5E5E5">Installing on Mac OS X</h3>
<p>First of all we must install two dependencies: <code>freetds</code> and <code>libiodbc</code>. Let&#8217;s use MacPorts for this (<a title="MacPorts" href="http://www.macports.org/">http://www.macports.org/</a>). The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system.</p>
<p><pre><code>sudo port install freetds
sudo port install libiodbc</code></pre></p>
<p>Now we have to install pyodbc and django-pyodbc (in your virtualenv of course!)</p>
<p><pre><code>pip install pyodbc
pip install svn+http://django-pyodbc.googlecode.com/svn/trunk/#django-pyodbc</code></pre></p>
<p>When everything is ready we can set up odbc. To do this open ODBC Manager -&gt; Drivers -&gt; Add&#8230; and enter this data (change path if needed):</p>
<p>Driver Name: <code>FreeTDS</code><br />
Driver file: <code>/opt/local/var/macports/software/freetds/0.82_0/opt/local/lib/libtdsodbc.so</code></p>
<p>It appears as if the system stores ODBC configuration data in <code>/Library/ODBC</code>, but the Mac Ports stores configuration in <code>/opt/local/etc</code>. So lets do some symlinks:</p>
<p><pre><code>sudo ln -s /Library/ODBC/odbc.ini /opt/local/etc/odbc.ini
sudo ln -s /Library/ODBC/odbcinst.ini /opt/local/etc/odbcinst.ini</code></pre></p>
<p>That&#8217;s it!</p>
<h3 style="color:#E5E5E5">Installing on Ubuntu</h3>
<p>First of all we must install two dependencies: freetds and libiodbc.</p>
<p><pre><code>sudo aptitude install unixodbc unixodbc-dev freetds-dev tdsodbc</code></pre></p>
<p>Then we install pyodbc and django-pyodbc:</p>
<p><pre><code>pip install pyodbc
pip install svn+http://django-pyodbc.googlecode.com/svn/trunk/#django-pyodbc</code></pre></p>
<p>When we have all in place, we must set up odbc. To do this edit odbcinst.ini file (change path if needed):</p>
<p>- <code>sudo vim /etc/odbcinst.ini</code></p>
<p>and paste this configuration:</p>
<p><pre><code>[FreeTDS]
    Description = TDS driver (Sybase/MS SQL)
    Driver = /usr/lib/odbc/libtdsodbc.so
    Setup = /usr/lib/odbc/libtdsS.so
    CPTimeout =
    CPReuse =</code></pre></p>
<p>You are ready to use MSSQL now!</p>
<h3 style="color:#E5E5E5">Django Settings</h3>
<p>Last step is proper settings file. Here is an example:</p>
<p><pre><code>DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'DB NAME',
        'HOST': 'HOST IP',
        'USER': 'USER',
        'PASSWORD': 'PSW',
        'PORT': 1433,
        'OPTIONS': {
            'driver': 'FreeTDS',
            'host_is_server': True,
            'extra_params': &quot;TDS_VERSION=8.0&quot;
        }
     } 
}</code></pre></p>
<p>Most important are ENGINE and OPTIONS.</p>
<p><code>'ENGINE'</code> should be set to <code>'sql_server.pyodbc'</code><br />
<code>'driver'</code> name is a name used in odbc configuration.<br />
If you use remote db, you must use `<code>'host_is_server': True</code>` parameter.<br />
Last important param is &#8220;<code>TDS_VERSION=8.0</code>&#8220;. We must declare TDS protocol version.</p>
<p>After all these steps, you should be able to connect MSSQL successfully.</p>
<h3 style="color:#E5E5E5">Troubleshooting</h3>
<p>You might encounter an error when trying to read Decimal fields: <code>MemoryError of fetching results</code>. &#8211; on Mac OS X<br />
<code>HY003 Program type out of range (SQLGetData() )</code> when trying read numerical field (MSSQL) &#8211; on Ubuntu</p>
<p>It seems that problem was fixed by wesm at github:</p>
<p><a href="https://github.com/wesm/pyodbc/tree/getdata-decimal-bug" target="_blank">https://github.com/wesm/pyodbc/tree/getdata-decimal-bug</a></p>
<p>When you update pyodbc with this build (pyodbc 2.1.10-beta04) problems should dissapear! Hope this post was helpful and saved you some development time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tivix.com/2012/02/08/getting-django-working-with-mssql-pyodbc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>5 open-source Python/Django apps we love</title>
		<link>http://blog.tivix.com/2012/01/30/5-open-source-python-django-apps-we-love-and-are-must-have/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=5-open-source-python-django-apps-we-love-and-are-must-have</link>
		<comments>http://blog.tivix.com/2012/01/30/5-open-source-python-django-apps-we-love-and-are-must-have/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 01:40:53 +0000</pubDate>
		<dc:creator>Dariusz Fryta</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[compressor]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[fabric]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[south]]></category>
		<category><![CDATA[Tastypie]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[tivix]]></category>

		<guid isPermaLink="false">http://blog.tivix.com/?p=1916</guid>
		<description><![CDATA[The Python/Django duet is fantastic, everyone knows that. However it can be even more awesome with these apps: 1. South This is an intelligent schema and data migration tool. If you don’t use it yet, you will want to after &#8230; <a href="http://blog.tivix.com/2012/01/30/5-open-source-python-django-apps-we-love-and-are-must-have/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.tivix.com/wp-content/uploads/2012/01/python-django.png"><img class="alignright size-full wp-image-1952" style="margin: 0 0 10px 10px;" title="python-django" src="http://blog.tivix.com/wp-content/uploads/2012/01/python-django.png" alt="" width="211" height="192" /></a></p>
<p>The Python/Django duet is fantastic, everyone knows that. However it can be even more awesome with these apps:</p>
<h3 style="color:#E5E5E5">1. South</h3>
<p>This is an intelligent schema and data migration tool. If you don’t use it yet, you will want to after reading this post. Okay&#8230; but what it is exactly?</p>
<p>When you create a Django app, you are using the &#8220;syncdb&#8221; command. After a model changes you have to delete the whole database and run &#8220;syncdb,&#8221; or manually do SQL changes directly in the database. It’s even more tragic when you already have production data. Not so fun, right?</p>
<p>Enter our hero: &#8220;South.&#8221; Its main objectives are to provide a simple, stable and database-independent migration layer to prevent all the hassles schema changes bring to your Django applications over time.</p>
<p><strong>Simple example</strong></p>
<p>Let&#8217;s create a model in our &#8220;southtut&#8221; app:</p>
<p><pre><code>class Knight(models.Model):
    name = models.CharField(max_length=100)
    of_the_round_table = models.BooleanField()</code></pre></p>
<p>Then let’s create our first migration:</p>
<p><code><br />
$ ./manage.py schemamigration southtut --initial<br />
Creating migrations directory at '/home/andrew/Programs/litret/southtut/migrations'...<br />
Creating __init__.py in '/home/andrew/Programs/litret/southtut/migrations'...<br />
+ Added model southtut.Knight<br />
Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate southtut<br />
</code></p>
<p>And apply our new migration:</p>
<p><code><br />
$ ./manage.py migrate southtut<br />
Running migrations for southtut:<br />
- Migrating forwards to 0001_initial.<br />
&gt; southtut:0001_initial<br />
- Loading initial data for southtut.<br />
</code></p>
<p>Very similar to &#8220;syncdb,&#8221; for now. But now time for magic! Let’s modify the model:</p>
<p><pre><code>class Knight(models.Model):
    name = models.CharField(max_length=100)
    of_the_round_table = models.BooleanField()
    dances_whenever_able = models.BooleanField()</code></pre></p>
<p>To apply these changes we have to run these two commands:</p>
<p><code><br />
$ ./manage.py schemamigration southtut --auto<br />
$ ./manage.py migrate southtut<br />
</code></p>
<p>And that’s all! All data is in place with the new structure.</p>
<p>Read more here: <a title="http://south.aeracode.org/" href="http://south.aeracode.org/">http://south.aeracode.org/</a></p>
<h3 style="color:#E5E5E5">2. Fabric </h3>
<p>Fabric is the second must have app. Fabric is a Python library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.</p>
<p>It provides a basic suite of operations for executing local or remote shell commands (normally or via sudo) and uploading/downloading files, as well as auxiliary functionality such as prompting the running user for input, or aborting execution.</p>
<p><strong>Small example:</strong></p>
<p>You are working on a Django app locally. After you finish working, you commit all changes to a repository. Now you want to deploy all the changes to staging or production server. This is what it normally looks like:</p>
<p>- open new console<br />
- connect with server via SSH<br />
- run virtual environment (if any)<br />
- install any new requirements<br />
- pull all changes from repository<br />
- run syncdb, migrations (if South is used)<br />
- collect static files<br />
- delete *.pyc files (to be sure)<br />
- restart apache/nginx or whatever server you have using<br />
- restart memcache</p>
<p>10 steps and we are ready. But&#8230; how about doing same thing using only one line? Simple — use Fabric. With the proper configuration of all these steps we can close in this line:</p>
<p><code><br />
$ fab production launch<br />
</code></p>
<p>Here you can read more: <a title="http://fabfile.org" href="http://fabfile.org">http://fabfile.org</a></p>
<h3 style="color:#E5E5E5">3. Django compressor</h3>
<p>What we would like to achieve in our website:</p>
<p>- every file is downloaded from server only ONCE (every next time cache is used)<br />
- only one CSS and JS file is downloaded<br />
- client browser always knows what file is actual and what file should be downloaded again</p>
<p>All of that is possible with Django Compressor.</p>
<p>Django Compressor combines and compresses linked and inline Javascript or CSS in a Django template into cacheable static files by using the &#8220;compress&#8221; template tag.</p>
<p><strong>Example:</strong></p>
<p><pre><code>{% load compress %}

{% compress css %}

{% endcompress %}</code></pre></p>
<p>Which would be rendered all in one file:</p>
<p><pre><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;/static/CACHE/css/optimized_file.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot;&gt;</code></pre></p>
<p>More information here: <a title="https://github.com/jezdez/django_compressor" href="https://github.com/jezdez/django_compressor">https://github.com/jezdez/django_compressor</a></p>
<h3 style="color:#E5E5E5">4. Tastypie</h3>
<p>Sometimes we have to add an API to our application without the ability to modify the sources of that app. Tastypie is exactly what we need. It provides a convenient yet powerful and highly customizable abstraction for creating REST-style interfaces. It relies only on its own code and focuses on providing a REST-style API.<br />
Let’s create a resource class for our model &#8220;Knight&#8221;:</p>
<p><pre><code>from tastypie.resources import ModelResource
from southtut.models import Knight

class KnightResource(ModelResource):
    class Meta:
        queryset = Knight.objects.all()
        resource_name = 'knight'</code></pre></p>
<p>Now we have to hook up a resource:</p>
<p><pre><code>from django.conf.urls.defaults import *
from southtut.api import KnightResource

knight_resource = KnightResource()

urlpatterns = patterns('',
# ...
(r'^southtut/', include('southtut.urls')),
(r'^api/', include(knight_resource.urls)),
)</code></pre></p>
<p>And voila! We have set up our REST interface. Our resource is available at these urls:</p>
<p><code></p>
<p>http://127.0.0.1:8000/api/knight/?format=json</p>
<p>http://127.0.0.1:8000/api/knight/1/?format=json</p>
<p>http://127.0.0.1:8000/api/knight/schema/?format=json</p>
<p>etc...<br />
</code></p>
<p>Of course, this is only one simple example. For safety, Tastypie ships with the authorization class and many more.</p>
<p>More information: <a title="http://tastypieapi.org/" href="http://tastypieapi.org/">http://tastypieapi.org/</a></p>
<h3 style="color:#E5E5E5">5. Easy thumbnails</h3>
<p>There are many apps for thumbnails. However, this one is the simplest and most powerful I’ve ever seen. We only have to add <strong>&#8216;easy_thumbnails&#8217;</strong> in <strong>INSTALLED_APPS</strong>.</p>
<p>It’s great for quick thumbnails in template usage:</p>
<p><pre><code>{% load thumbnail %}
{% thumbnail [source] [size] [options] %}</code></pre></p>
<p><strong>where:</strong></p>
<p>- source must be a File object, usually an Image/FileField of a model instance,<br />
- size in the format [width]x[height]<br />
- list of options like sharpen, crop, and quality=90</p>
<p>And that’s all. The thumbnail is created dynamically (if it doesn&#8217;t exist) when the page is requested.</p>
<p>Of course, there is Model and Low Level usage too.</p>
<p>More information: <a title="https://github.com/SmileyChris/easy-thumbnails" href="https://github.com/SmileyChris/easy-thumbnails">https://github.com/SmileyChris/easy-thumbnails</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tivix.com/2012/01/30/5-open-source-python-django-apps-we-love-and-are-must-have/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Django Common App (Part 1)</title>
		<link>http://blog.tivix.com/2012/01/13/django-common-app-part-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=django-common-app-part-1</link>
		<comments>http://blog.tivix.com/2012/01/13/django-common-app-part-1/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 19:23:34 +0000</pubDate>
		<dc:creator>Matthew Farver</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[overview]]></category>

		<guid isPermaLink="false">http://blog.tivix.com/?p=1889</guid>
		<description><![CDATA[Here at Tivix we&#8217;ve created a number of open source apps that are available for use. In this post we&#8217;re going to talk specifically about the django-common app, which provides functionality commonly needed in a django application (in case it &#8230; <a href="http://blog.tivix.com/2012/01/13/django-common-app-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here at Tivix we&#8217;ve created a number of <a title="Tivix Open Source Apps" href="http://www.tivix.com/work/category/labs-open-source/">open source apps</a> that are available for use.</p>
<p>In this post we&#8217;re going to talk specifically about the <a title="Github Django Common" href="https://github.com/Tivix/django-common">django-common</a> app, which provides functionality commonly needed in a django application (in case it wasn&#8217;t obvious).</p>
<p><code><br />
<h3>WWWRedirectMiddleware</h3>
<p></code></p>
<p>WWWRedirectMiddleware redirects requests to make sure they are on the www subdomain or off the www subdomain, depending on your settings.  Besides adding &#8216;<code>django_common.middleware.WWWRedirectMiddleware</code>&#8216; to <code>MIDDLEWARE_CLASSES</code>, you need to set <code>DOMAIN_NAME</code> in the settings, either with www or not.  You need to also set IS_PROD to true, as you don&#8217;t want to redirect on localhost.</p>
<p><code><br />
<h3>SSLRedirectMiddleware and NoSSLRedirectMiddleware</h3>
<p></code></p>
<p>SSLRedirectMiddleware redirects requests to make sure that they are under https.  NoSSLRedirectMiddleware makes sure they are under http.</p>
<p><code><br />
<h3>ssl_required decorator</h3>
<p></code></p>
<p>If you don&#8217;t need ssl across the entire site (you oftentimes don&#8217;t) you can simply use the ssl_required decorator on the specific view that requires https.</p>
<p><code><br />
<h3>disable_for_loaddata decorator</h3>
<p></code></p>
<p>This decorator is used to wrap signals instead of views.  It disables signals from being fired when the loaddata command is run.  See: <a title="Django Code Ticket 8399" href="https://code.djangoproject.com/ticket/8399">https://code.djangoproject.com/ticket/8399</a></p>
<p><code><br />
<h3>EmailBackend</h3>
<p></code></p>
<p>The EmailBackend is an authentication backend that works like the default &#8216;<code>django.contrib.auth.backends.ModelBackend</code>&#8216; except it finds users by email instead of username.  To use it simply add &#8216;<code>django_common.auth_backends.EmailBackend</code>&#8216; to <code>AUTHENTICATION_BACKENDS</code> in the settings.</p>
<p>These are just a few features available in the django_common app.  Stay posted for more posts on the django_common app, but of course the best way to find out all the functionality is to check out the <a title="Github Django Common" href="https://github.com/Tivix/django-common">app itself</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tivix.com/2012/01/13/django-common-app-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Responsive Web Design</title>
		<link>http://blog.tivix.com/2012/01/11/responsive-web-design/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=responsive-web-design</link>
		<comments>http://blog.tivix.com/2012/01/11/responsive-web-design/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 18:58:39 +0000</pubDate>
		<dc:creator>Benjamin Pruitt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[General Technology]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[flexible]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[responsive design]]></category>

		<guid isPermaLink="false">http://blog.tivix.com/?p=1870</guid>
		<description><![CDATA[We all know that mobile devices and tablet computers are experiencing explosive growth right now. So how do you make sure that a new website today looks as good on an Android phone and an iPad as it does on &#8230; <a href="http://blog.tivix.com/2012/01/11/responsive-web-design/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.tivix.com/wp-content/uploads/2012/01/bogo1.jpg"><img src="http://blog.tivix.com/wp-content/uploads/2012/01/bogo1-300x179.jpg" alt="" title="bogo" width="300" height="179" class="alignleft size-medium wp-image-1913" /></a>
<div>
<p dir="ltr">We all know that mobile devices and tablet computers are experiencing explosive growth right now. So how do you make sure that a new website today looks as good on an Android phone and an iPad as it does on a large computer screen?</p>
<p dir="ltr">Responsive Design is the idea that development and design on the web today should fluidly respond to the user’s environment based on the device platform, orientation of the device, and the overall size of the screen.</p>
<p dir="ltr">When incorporating Responsive Design into a website there are some key things to consider.  The site needs to be built inside of a flexible grid.  This will account for the screen size of the device and render the site differently based on it. Any images used within the design need to be flexible as well. And be sure to enable different views for different behaviors using media queries.</p>
<p dir="ltr">Creating the site within a flexible grid will allow the layout of the website to change based on the size of the browser’s viewport.  You can create this grid manually or use a pre-built framework such as<a href="http://getskeleton.com/"> Skeleton</a>.  Skeleton is a great framework already built to support responsive and mobile-friendly development.</p>
<p dir="ltr">The next piece to consider is what to do with the images you place in the design.  Images will need to scale and move within the flexible grid to allow users to see them on all kinds of devices. There are several solutions for this, but here are two popular ways of adding flexibility to your images:</p>
<p>1. Use the CSS overflow property (overflow: hidden) to dynamically crop images as the size of the containers they are in shift and change. The<a href="http://www.berkshiresalondayspa.com/"> “Berkshire Salon and Day Spa”</a> is a beautiful example of images cropping or disappearing altogether to accommodate device width — try resizing your browser window, and notice how the design responds to the viewer’s new dimensions.</p>
<p>2. The use of the CSS max-width property is an easy fix.  Set the &lt;img&gt; with a max-width of 100%.  This will narrow and widen your image to the width of the device or browser size.</p>
<p>Lastly, utilize media queries via CSS3.  This is nothing new to style sheets — defining what kind of media your style sheet will use has been around for quite some time.  A stylesheet designed for printing websites on paper (print.css) will differ from your core style sheet.  The same concept is used when defining style sheets for devices.  For example, you could create a style sheet that will only be used on devices with a maximum width of 480 pixels:</p>
<p><pre><code>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen and (max-device-width: 480px)&quot; href=&quot;style.css&quot; /&gt;</code></pre></p>
<p>Basically what this is doing is checking to see if the device uses a screen (as opposed to, say, print or braille) and if the device’s screen has a width equal to or less than 480 pixels (for example, an iPhone held in its portrait orientation).  If so, the page will be rendered using the CSS in the “style.css” style sheet.  For some great information on media queries and responsive design check out<a href="http://www.alistapart.com/articles/responsive-web-design/"> this amazing article</a> by Ethan Marcotte.</p>
<p dir="ltr">The recipe for responsive design is fairly simple, but it does require designers and developers to change their way of thinking to create for entirely new experiences and audiences.  Nevertheless, it’s exciting to think of the new era we are entering, creating custom solutions for a wide range of users on a wide range of devices.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tivix.com/2012/01/11/responsive-web-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending User Model in Django</title>
		<link>http://blog.tivix.com/2012/01/06/extending-user-model-in-django/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=extending-user-model-in-django</link>
		<comments>http://blog.tivix.com/2012/01/06/extending-user-model-in-django/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 00:07:49 +0000</pubDate>
		<dc:creator>Francis David Cleary</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.tivix.com/?p=1816</guid>
		<description><![CDATA[When building nearly every application in Django there comes a time where you want to associate more information with a user then just the built in ones. Django lets you as the programmer control how and where you want to handle this information. There &#8230; <a href="http://blog.tivix.com/2012/01/06/extending-user-model-in-django/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When building nearly every application in Django there comes a time where you want to associate more information with a user then just the <a target=_blank href="https://docs.djangoproject.com/en/dev/topics/auth/#fields">built in ones</a>. Django lets you as the programmer control how and where you want to handle this information.</p>
<p>There are several ways to do this, and there is no absolute right or wrong way.  This is just one way to manage extra user data and we find it very easy to use and manage.</p>
<p>First we create a user profile model (Like to create a separate &#8221;accounts&#8221; app to house this data).</p>
<p><pre><code>from django.contrib.auth.models import User
from django.db.models.signals import post_save

class UserProfile(models.Model):  
    user = models.OneToOneField(User)  
    #other fields here

    def __str__(self):  
          return &quot;%s's profile&quot; % self.user  

def create_user_profile(sender, instance, created, **kwargs):  
    if created:  
       profile, created = UserProfile.objects.get_or_create(user=instance)  

post_save.connect(create_user_profile, sender=User) 

User.profile = property(lambda u: u.get_profile() )</code></pre></p>
<p>As you can see above is a normal model with a foreign key to the Django User model. Then add any other fields you would want to store for a user: date of birth, website, favorate color, or whatever. Then we are going to tie a signal to the creation of users. In this case we use the django <a target=_blank href="https://docs.djangoproject.com/en/dev/ref/signals/#post-save">post_save signal</a> and set the sender as the User model. When a user is saved it will then call <code>create_user_profile</code>.<sub>1</sub></p>
<p>On <code>line 17</code> we are <a target=_blank href="http://en.wikipedia.org/wiki/Monkey_patch">monkey patching</a> the User object to have a new property. All this does is create a shortcut for our own use later.  So rather then typing <code>my_user.get_profile().fav_color</code> we can simply type <code>my_user.profile.fav_color</code></p>
<p>Under the hood they are the same but I find one is more aesthetically pleasing then the other.</p>
<p>Lastly we need to tell django that we have a user profile so that <code>my_user.get_profile()</code> works. In your settings.py simply add:</p>
<p><pre><code>AUTH_PROFILE_MODULE = 'YOURAPP.UserProfile'</code></pre></p>
<p>You can read more about this in the django docs for <a target=_blank href="https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users">storing additional information about users</a>.  <br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
<sub>1 </sub><small> <code>if created</code> is not really needed but is a good double check along with <code>UserProfile.objects.get_or_create</code>. Using this we should never have an error of any user duplications or any other weird bugs/quarks your code may produce. </small></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tivix.com/2012/01/06/extending-user-model-in-django/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Some Trends for 2012</title>
		<link>http://blog.tivix.com/2012/01/01/some-technology-trends-for-2012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=some-technology-trends-for-2012</link>
		<comments>http://blog.tivix.com/2012/01/01/some-technology-trends-for-2012/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 02:24:05 +0000</pubDate>
		<dc:creator>Bret Waters</dc:creator>
				<category><![CDATA[General Technology]]></category>

		<guid isPermaLink="false">http://tivixblog.wordpress.tivixlabs.com/?p=1709</guid>
		<description><![CDATA[This is the time of year when tech bloggers everywhere post predictions for the new year. My prediction for 2012 is simple: this year will be about convergence. The previous software application waves called “desktop”, “web”, “social”, “mobile”, and “cloud” &#8230; <a href="http://blog.tivix.com/2012/01/01/some-technology-trends-for-2012/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.tivix.com/wp-content/uploads/2012/01/convergence250.jpg"><img class="alignleft size-full wp-image-1713" title="convergence250" src="http://blog.tivix.com/wp-content/uploads/2012/01/convergence250.jpg" alt="" width="250" height="166" /></a>This is the time of year when tech bloggers everywhere post predictions for the new year. My prediction for 2012 is simple: <strong>this year will be about convergence.</strong> The previous software application waves called “desktop”, “web”, “social”, “mobile”, and “cloud” will converge, as the lines between them will continue to blur.</p>
<p>In the end, an application is an application. And users today want to be able to use that application anywhere, from any device, and have their personal content just magically appear.</p>
<p>This is as true for consumers as it is for office workers. As a consumer, I want my Amazon.com experience to be seamless on my computer, my iPad, and my iPhone. And when I’m at work I want to be able to create a spreadsheet, work on it anywhere, and collaborate on it with my office colleagues anywhere.</p>
<p>For developers, of course, the challenge is creating software applications which deliver a high-quality user experience across many different devices. But 2012 technologies will make it easier than ever for software engineers to “write once, run many&#8221;. New applications will no longer need a desktop version, a web version, and a mobile version. Convergence allows us to develop one version, available to users everywhere. <strong>That’s a huge opportunity.</strong></p>
<p>Here are some other trends we expect to be a big part of the year ahead:</p>
<p><strong>Mobile First</strong><br />
For most websites and applications, mobile is clearly the growth area. According to <a href="http://www.gartner.com/technology/home.jsp">Gartner Research</a>, smartphones and tablets will represent more than 90 percent of the growth of device adoption in the coming four years. So any new online initiative needs to <strong>start</strong> by looking at how to create a high quality experience for mobile users.</p>
<p><strong>Open Standard Technologies Rule</strong><br />
Making a software application perform well across multiple platforms requires an absolute commitment to open standards. In 2011 we saw <a href="http://en.wikipedia.org/wiki/Adobe_Flash">Flash</a>, a proprietary (“semi-open”) technology die-off for just this reason. At Tivix our standard development stack is LAMP (P=Python), Django, HTML, CSS, and JavaScript &#8211; all open-source, standards-based technologies. In 2012 <strong>HTML5</strong> will be the most important standard of all, bringing a whole suite of open technologies which work across all devices – from computers to tablets to mobile phones.</p>
<p><strong>Infrastructure Disappears</strong><br />
The essential benefit of cloud computing (and its cousin, Software-as-a-Service) is that users don&#8217;t to have to purchase, install, and configure anything; computing is just delivered to them as an on-demand service. The same is true for us as developers. Today, with solutions like <a href="http://aws.amazon.com/">AWS</a> or <a href="http://www.linode.com/">Linode</a>, we can have an entire set of servers configured and running in a half-hour, with zero capital investment. This is huge, especially for the kind of development speed and agility our clients want from us today. In 2012 infrastructure will continue to become invisible, reliable, and essentially infinitely-scalable.</p>
<p><strong>User Experience is More Important than Ever</strong><br />
The bar is set high today. Users expect even a simple website or enterprise application to have the same quality of user experience they get on Facebook or Google. On top of that, a user interface today has to work well on many different screen sizes, from large monitors to tablets to small smartphones. 2012 will see the embracing of <a href="http://designmodo.com/responsive-design-examples/">Responsive Design</a> techniques, where the design of the user interface automatically and fluidly adjusts for the user’s device and screen size. For some great examples of Responsive Design, see <a href="http://foodsense.is/">Foodsense</a>, the <a href="http://www.bostonglobe.com/">Boston Globe</a>, and <a href="http://us.illyissimo.com/">Illy</a> (open and close the width of your browser window and watch how the design automatically adjust itself for any screen size, including mobile).</p>
<p>2012 will feature many other tech trends as well, of course. Social will continue to be huge, as will the geolocation capabilities of mobile. And the combination of the two will continue to drive opportunities to deliver context-aware content to users. The proliferation of mobile payment solutions will mean that consumers will become increasingly comfortable using their smartphones for shopping and purchasing. And video of all kinds will continue to be the largest growth category of online content.</p>
<p>But mostly, 2012 will be about convergence. At Tivix, we see nothing be great opportunities ahead. It’s going to be an exciting year.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tivix.com/2012/01/01/some-technology-trends-for-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 833/956 objects using disk: basic

Served from: blog.tivix.com @ 2012-05-18 13:50:47 -->
