<?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>NinjaCipher &#187; django</title>
	<atom:link href="http://www.ninjacipher.com/category/development/python/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ninjacipher.com</link>
	<description>kungpow programming</description>
	<lastBuildDate>Thu, 25 Mar 2010 14:39:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='www.ninjacipher.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Selling clients on Django</title>
		<link>http://www.ninjacipher.com/2009/05/06/selling-clients-on-django/</link>
		<comments>http://www.ninjacipher.com/2009/05/06/selling-clients-on-django/#comments</comments>
		<pubDate>Thu, 07 May 2009 01:39:23 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=143</guid>
		<description><![CDATA[So right up front let me just say that I love Django. This should come as no surprise to anyone who has been to my site. I think its a great framework and I really enjoy working with it. That being said all too often my clients look like a deer in headlights when I [...]]]></description>
			<content:encoded><![CDATA[<p>So right up front let me just say that I love Django. This should come as no surprise to anyone who has been to my site. I think its a great framework and I really enjoy working with it. That being said all too often my clients look like a deer in headlights when I suggest using it for their projects. Unfortunately that usually means that they want to use&#8230; PHP ::dies::</p>
<p>Now not that there aren&#8217;t some decent PHP frameworks out there but lets be honest if I had my druthers the clear winner would ALWAYS be Python/Django. Once in awhile I will get someone who is a little bit more open minded and they will suggest Rails. Which again is fine&#8230; I would rather write Ruby then PHP any day but it still is a far cry from Django IMHO. </p>
<p>So my question is this&#8230; how do you sell a client on the idea of using Django?! I would love to hear your thoughts about it. To preface my client base is normally entertainment industry based (Record labels, TV networks and Movie Studios). They tend to have overly bloated IT departments that take 7 months to handle an app we can crank out in a matter of weeks. The usual roadblocks I hear are &#8220;we don&#8217;t support python&#8221; or &#8220;we have no python resources to maintain the app after your done&#8221;. Basically I think my clients tend to think that I&#8217;m suggesting they build in Django not out of trying to use the best tool for the job but more as a job security language (jsl).   </p>
<p>Anyway as you can prob tell this is a constant source of frustration and any advice would be very much appreciated. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2009/05/06/selling-clients-on-django/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Top 5 Django IDEs</title>
		<link>http://www.ninjacipher.com/2009/05/01/top-5-django-ides/</link>
		<comments>http://www.ninjacipher.com/2009/05/01/top-5-django-ides/#comments</comments>
		<pubDate>Sat, 02 May 2009 03:22:24 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[random thoughts]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ide]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=108</guid>
		<description><![CDATA[I&#8217;ve seen a lot of people out there looking for a good IDE for doing Django work. Personally I&#8217;m a pydev guy. I have been using Eclipse for so long for everything else it&#8217;s very natural to keep on that path. However there are definitely other alternatives out there. Here is a list of other [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen a lot of people out there looking for a good IDE for doing Django work. Personally I&#8217;m a pydev guy. I have been using Eclipse for so long for everything else it&#8217;s very natural to keep on that path. However there are definitely other alternatives out there. Here is a list of other IDEs and editors that have Django support.</p>
<ol>
<li><a href="http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html" target="_blank">Eclipse with PyDev</a> (part of <a href="http://www.aptana.com/python" target="_blank">Aptana</a> now)</li>
<li><a href="http://macromates.com/blog/archives/2006/08/21/getting-more-bundles/" target="_blank">TextMate with Django Bundle</a> (technically not an IDE but allot of people love it)</li>
<li><a href="http://code.google.com/p/netbeans-django/" target="_blank">Netbeans with Django Plugin</a></li>
<li><a href="http://www.wingware.com/doc/howtos/django" target="_blank">Wing</a></li>
<li><a href="http://code.google.com/p/django-komodo-kit/" target="_blank">Komodo with Django Komodo Kit</a></li>
</ol>
<p>So I&#8217;m sure some of you people out there will say man up&#8230; use VIM or Emacs&#8230; be a real programmer! To that I say have at it. If that&#8217;s your preference then do what works best for you. By all means, leave me a comment and tell my how wrong I am and/or glow about how good your IDE/editor is. Long story short Django is an awesome framework and whatever you choose to work in I hope you enjoy it as much as I have.</p>
<div id="stb-container" class="stb-container"><div id='caption' class='stb-alert-caption_box' >Reality Check!</div><div id='body' class='stb-alert-body_box' >Of course there are other options out there. And top 5 doesn&#8217;t mean these are the best. But from my research these are the editors most people seem to be using.<br />
</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2009/05/01/top-5-django-ides/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>django active_login_required decorator</title>
		<link>http://www.ninjacipher.com/2008/11/29/django-active_login_required-decorator/</link>
		<comments>http://www.ninjacipher.com/2008/11/29/django-active_login_required-decorator/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 22:13:29 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[django auth decorator]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=54</guid>
		<description><![CDATA[Here is a little hack I made to the auth.login_required decorator that checks to see if the user account has the is_active flag set as well as being logged in. Nothing earth shattering here but I find it useful. If you look at the original login_required decorator you will see its exactly the same except [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little hack I made to the auth.login_required decorator that checks to see if the user account has the is_active flag set as well as being logged in. Nothing earth shattering here but I find it useful. If you look at the original login_required decorator you will see its exactly the same except for the extra is_active flag check. </p>
<pre name="code" class="python">
#A decorator that checks to makes sure a user is active and logged in

from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test
def active_login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME):
    actual_decorator = user_passes_test(
        lambda u: u.is_authenticated() and u.is_active,
        redirect_field_name=redirect_field_name
    )
    if function:
        return actual_decorator(function)
    return actual_decorator</pre>
<p>You use it in the exact same way you use the normal login_required decorator.</p>
<p><strong>In your view</strong></p>
<pre name="code" class="python">@active_login_required
def my_view(request):
    # ...</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/11/29/django-active_login_required-decorator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Django Paginator Example</title>
		<link>http://www.ninjacipher.com/2008/08/04/new-django-paginator-example/</link>
		<comments>http://www.ninjacipher.com/2008/08/04/new-django-paginator-example/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 17:06:28 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=52</guid>
		<description><![CDATA[edit:
This example has since been added to the official Django Docs for pagination. Big thanks to Scot Hacker for taking the initiative to submit the doc patch and make this happen (IE I&#8217;m far to lazy to submit it on my own). 
So I pulled the latest Django codebase from svn today and I noticed [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #999999;"><em>edit:</em></span><br />
<span style="color: #808080;"><strong>This example has since been added to the <a title="django docs" href="http://docs.djangoproject.com/en/dev/topics/pagination/#using-paginator-in-a-view" target="_blank">official Django Docs for pagination</a>. Big thanks to <a title="birdhouse.org" href="http://birdhouse.org/blog/" target="_blank">Scot Hacker</a> for taking the initiative to submit the doc patch and make this happen (IE I&#8217;m far to lazy to submit it on my own). </strong></span></p>
<p>So I pulled the latest Django codebase from svn today and I noticed that my old pagination setup no longer works. Not really surprising as a ton of stuff is being updated due to the coming release of 1.0. So I did a bit of digging into the new pagination code to see if I could rework my <a href="http://www.ninjacipher.com/2007/12/27/django-pagination-wrapper/" target="_blank">wrapper class</a> to work with the new release. It turns out that with the updates there really is no good reason to wrap the classes any more. They have done a good job of working out all the kinks in the pagination setup and it does everything I need it to do out of the box.</p>
<p>So here is a quick nutshell example of how I am using the new django.core.paginator classes to replace the old ObjectPaginator wrapper from my <a href="http://www.ninjacipher.com/2007/12/27/django-pagination-wrapper/" target="_blank">previous example</a>.<br />
<strong><br />
in your view:</strong></p>
<pre name="code" class="python">from django.core.paginator import Paginator

#create a new paginator instance by passing it a collection of objects and the per page count
paginator = Paginator(Contact.objects.all().order_by('last_name'), 10)

#get the page number from a get param
#if param is blank then set page to 1
page = int(request.GET.get('page', '1'))

#grab the current page from the paginator...
contacts = paginator.page(page)

#render the template and pass the contacts page into the template
return render_to_response('contacts.html',{'contacts':contacts})</code>

<strong>in your template:</strong>
<code lang="python">{% for contact in contacts.object_list %}
{{ contact.name }}
{% endfor %}</pre>
<p>I'd say that's pretty easy. </p>
<p>Here is a  simple snippet that you can use to create a paging footer.</p>
<pre name="code" class="python">
<div class="pagination">
	<span class="step-links">
	{% if contacts.has_previous %}<a href="?page={{ contacts.previous_page_number }}" class="util-link">previous</a>{% endif %}
	{% if contacts.has_next %}<a href="?page={{ contacts.next_page_number }}" class="util-link">next</a>{% endif %}
	</span>
	<span class="current">
		{{ contacts }}
	</span>
</div>
</pre>
<p>Notice to get the page of pages info all you have to do is output the page object like so... {{ contacts }} . Pretty cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/08/04/new-django-paginator-example/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>group_required decorator</title>
		<link>http://www.ninjacipher.com/2008/06/20/group_required-decorator/</link>
		<comments>http://www.ninjacipher.com/2008/06/20/group_required-decorator/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 19:17:56 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/?p=49</guid>
		<description><![CDATA[Here is a decorator that I came up with to augment the already available login_required and permission_required decorators. This one takes a group name and makes sure the logged in user is a part of it.
def group_required(group_name, login_url='/accounts/login/'):
    def wrap(view_func):
        def in_group(request, *args, **kwargs):
  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a decorator that I came up with to augment the already available login_required and permission_required decorators. This one takes a group name and makes sure the logged in user is a part of it.</p>
<pre name="code" class="python">def group_required(group_name, login_url='/accounts/login/'):
    def wrap(view_func):
        def in_group(request, *args, **kwargs):
            from django.contrib.auth.models import Group
            try:
                group = request.user.groups.get(name=group_name)
            except Group.DoesNotExist:
                from django.http import HttpResponseRedirect
                return HttpResponseRedirect(login_url)
            else:
                return view_func(request, *args, **kwargs)

        return in_group
    return wrap
</pre>
<p>to use</p>
<pre name="code" class="python">@group_required('groupies')
def index(request):
   ...
</pre>
<p>I&#8217;m posting this with a disclaimer up front. Every time I post what I think is a clever snippet someone always tells me that I am reinventing the wheel and it already exists in django. So if this is another case of me being tragically uninformed then please let me know as I would most likely use the official way instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/06/20/group_required-decorator/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding InnoDB to sqlall output</title>
		<link>http://www.ninjacipher.com/2008/03/23/adding-innodb-to-sqlall-output/</link>
		<comments>http://www.ninjacipher.com/2008/03/23/adding-innodb-to-sqlall-output/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 16:41:01 +0000</pubDate>
		<dc:creator>mattd</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.ninjacipher.com/2008/03/23/adding-innodb-to-sqlall-output/</guid>
		<description><![CDATA[Have you ever wondered why you can&#8217;t have manage.py sqlall output your create table statements as InnoDB tables for mysql? Well I have. I always go in and update the statements by hand to add that after the fact. So I did a bit of pokeing around and figured out a hack to add in [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wondered why you can&#8217;t have manage.py sqlall output your create table statements as InnoDB tables for mysql? Well I have. I always go in and update the statements by hand to add that after the fact. So I did a bit of pokeing around and figured out a hack to add in a settings flag so you can set the table type that your manage.py will use for its create table statements.</p>
<p>There are 2 changes you need to make. First off you need to add the following setting in your settings.py</p>
<pre>
DATABASE_TABLE_ENGINE = 'InnoDB'</pre>
<p>the other part is an update to the django.core.management.sql file. This file is really long (even though the actual hack is short). Basically the update is adding the following code in the many_to_many_sql_for_model and sql_model_create functions.</p>
<pre>
try:
   if settings.DATABASE_TABLE_ENGINE != None:
      table_output.append('ENGINE=%s' % settings.DATABASE_TABLE_ENGINE)
except:
   pass</pre>
<p>It&#8217;s really pretty basic but personally I find it useful. Now (here comes the disclaimer) I can&#8217;t guarantee that there isn&#8217;t already a way to do this. Despite all my digging I didn&#8217;t find it if it does exist. Also I&#8217;m sure there is a better way to add this update then going in and hacking the core script (or even if that&#8217;s playing nice and submitting an enhancement ticket which I should really read up on). On that note I would suggest not just swapping out the download version for your version. It would prob be best to just use my version as a guide to show you how to update your own sql.py so you don&#8217;t run into any file version probs. Just for the sake of clarity I&#8217;m running django svn trunk version 6898.</p>
<p><em>Edit</em> I noticed my local django version was pretty damn old so I just updated to 7353. The hack still seems to be working fine. <em>End Edit</em></p>
<p>You can download a copy of my hacked sql.py here: <a href="http://www.ninjacipher.com/wp-content/uploads/2008/03/sqlpy.zip" title="updated django.core.management.sql">updated django.core.management.sql</a> . As always use at your own risk and let me know what could be done better.</p>
<p><em>Edit</em> I&#8217;m adding a svn diff as well for those of you who would rather see only the changes: <a href='http://www.ninjacipher.com/wp-content/uploads/2008/03/table-engine-sql.diff' title='download diff'>download diff</a><em>End Edit</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ninjacipher.com/2008/03/23/adding-innodb-to-sqlall-output/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
