<?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>Meio Código &#187; Django</title>
	<atom:link href="http://www.meiocodigo.com/category/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.meiocodigo.com</link>
	<description>A peça que faltava para seu código.</description>
	<lastBuildDate>Sat, 14 Jan 2012 18:44:01 +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>django-meio-easytags 0.4 released!</title>
		<link>http://www.meiocodigo.com/2011/03/02/django-meio-easytags-0-4-released/</link>
		<comments>http://www.meiocodigo.com/2011/03/02/django-meio-easytags-0-4-released/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 04:53:32 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[template filters]]></category>
		<category><![CDATA[template tags]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=519</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2011/03/02/django-meio-easytags-0-4-released/' addthis:title='django-meio-easytags 0.4 released! '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>I just released the version 0.4 of the django-meio-easytags. I added a subclass of django&#8217;s default template tags Library. And now it&#8217;s easier to create a template tag. Take a look. Projects page Read the Docs Download from Github]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2011/03/02/django-meio-easytags-0-4-released/' addthis:title='django-meio-easytags 0.4 released! '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I just released the version 0.4 of the django-meio-easytags. I added a subclass of django&#8217;s default template tags Library. And now it&#8217;s easier to create a template tag. Take a look.</p>

<p><a href="http://meiocodigo.com/projects/django-meio-easytags/">Projects page</a></p>

<p><a href="http://readthedocs.org/docs/django-meio-easytags/en/latest/index.html">Read the Docs</a></p>

<p><a href="https://github.com/vbmendes/django-meio-easytags">Download from Github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2011/03/02/django-meio-easytags-0-4-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>django-meio-easytags 0.3 released!</title>
		<link>http://www.meiocodigo.com/2011/02/26/django-meio-easytags-0-3-released/</link>
		<comments>http://www.meiocodigo.com/2011/02/26/django-meio-easytags-0-3-released/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 02:25:49 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[template filters]]></category>
		<category><![CDATA[template tags]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=513</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2011/02/26/django-meio-easytags-0-3-released/' addthis:title='django-meio-easytags 0.3 released! '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>I released today the version 0.3 of django-meio-easytags. Now it supports template tags that accepts positional arguments (&#42;args) and keyword arguments (&#42;&#42;kwargs). If you don&#8217;t know how to use this, take a look at Python FAQ. In this release I included some documentation and created a page for the project. Any doubts, suggestions, feature requests, [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2011/02/26/django-meio-easytags-0-3-released/' addthis:title='django-meio-easytags 0.3 released! '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I released today the version 0.3 of django-meio-easytags. Now it supports template tags that accepts positional arguments (&#42;args) and keyword arguments (&#42;&#42;kwargs). If you don&#8217;t know how to use this, take a look at <a href="http://docs.python.org/faq/programming#how-can-i-pass-optional-or-keyword-parameters-from-one-function-to-another">Python FAQ</a>. In this release I included some <a href="http://django-meio-easytags.readthedocs.org/en/latest/index.html">documentation</a> and created a <a href="http://meiocodigo.com/projects/django-meio-easytags/">page for the project</a>.</p>

<p>Any doubts, suggestions, feature requests, feel free to mail me, open an issue at Github or leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2011/02/26/django-meio-easytags-0-3-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>django-meio-easytags released!</title>
		<link>http://www.meiocodigo.com/2011/02/21/django-meio-easytags-released/</link>
		<comments>http://www.meiocodigo.com/2011/02/21/django-meio-easytags-released/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 04:41:03 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=503</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2011/02/21/django-meio-easytags-released/' addthis:title='django-meio-easytags released! '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>django-meio-easytags An easy way to create and parse custom template tags for Django's templating system.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2011/02/21/django-meio-easytags-released/' addthis:title='django-meio-easytags released! '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I just released a project I have been working today. A long time ago, I was tired of parsing my template tags by hand, then I created a BaseNode to do this work for me and all I had to do was subclass it and define the method to render the context.</p>

<p>Last friday, my friend <a href="http://www.diegofleury.com.br/">Diego Fleury</a> asked me for some help developing a template tag and I talked to him about my old BaseNode. When I showed the code to him, he didn&#8217;t understand it so did I. So I wanted to make it cleaner and developed the project django-meio-easytags. It&#8217;s hosted at Github (<a href="http://github.com/vbmendes/django-meio-easytags/">http://github.com/vbmendes/django-meio-easytags/</a>).</p>

<p>It&#8217;s very easy to create your own template tags with it. Take a look: <a href="https://github.com/vbmendes/django-meio-easytags/blob/master/README">https://github.com/vbmendes/django-meio-easytags/blob/master/README</a></p>

<p>Any comments and contributions are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2011/02/21/django-meio-easytags-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>get_first_object_or_none shortcut for Django</title>
		<link>http://www.meiocodigo.com/2010/03/28/get_first_object_or_none-shortcut-for-django/</link>
		<comments>http://www.meiocodigo.com/2010/03/28/get_first_object_or_none-shortcut-for-django/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 13:48:30 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[queryset]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=476</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2010/03/28/get_first_object_or_none-shortcut-for-django/' addthis:title='get_first_object_or_none shortcut for Django '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>I will talk about a shortcut I developed for the Django framework and always use in my apps. This code is aimed in making a quik shortcut to obtain the first object of a queryset if it exists or None otherwise. It&#8217;s very useful when you want to display the last news in the first [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2010/03/28/get_first_object_or_none-shortcut-for-django/' addthis:title='get_first_object_or_none shortcut for Django '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I will talk about a shortcut I developed for the <a href="http://www.djangoframework.com/">Django framework</a> and always use in my apps. This code is aimed in making a quik shortcut to obtain the first object of a queryset if it exists or <code>None</code> otherwise.</p>

<p>It&#8217;s very useful when you want to display the last news in the first page of your website, but don&#8217;t want it to break if there isn&#8217;t one to show. It&#8217;s just a use case for such a code, but there are many more.</p>

<p>In the past I used to write something like this:</p>

<p><pre class="brush: python">
try:
    first_user = User.objects.all()[:1][0]
except IndexError:
    first_user = None
</pre></p>

<p>This is four lines to do a very simple task and I wanted to evolve this to use only one line of code. So I developed a function that do this to me. It&#8217;s inspired in the <code>django.shortcuts.get_object_or_404</code>. Let&#8217;s take a look at the code:</p>

<p><pre class="brush: python">
def get_first_object_or_none(queryset):
    try:
        return queryset[:1][0]
    except IndexError:
        return None
</pre></p>

<p>I&#8217;ve put this code in a module called <code>shortcuts</code> inside my project and now everytime I want to use it I can write this code:</p>

<p><pre class="brush: python">
from shortcuts import get_first_object_or_none
first_user = get_first_object_or_none(User.objects.all())
</pre></p>

<p>I think it&#8217;s a very good result and helps a lot in my coding. It also made my code more legible and easy to understand. It increased my productivity and I am publishing to increase others productivity also. Any doubts, questions os suggestions, please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2010/03/28/get_first_object_or_none-shortcut-for-django/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Arquivos do Mini curso de Django disponibilizados</title>
		<link>http://www.meiocodigo.com/2009/04/26/arquivos-do-mini-curso-de-django-disponibilizados/</link>
		<comments>http://www.meiocodigo.com/2009/04/26/arquivos-do-mini-curso-de-django-disponibilizados/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 02:04:35 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[flisol]]></category>
		<category><![CDATA[mini-curso]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=361</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/04/26/arquivos-do-mini-curso-de-django-disponibilizados/' addthis:title='Arquivos do Mini curso de Django disponibilizados '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>No dia 24 de abril de 2009, no SENAC em Natal/RN, ocorreu o FLISOL. Neste evento, eu ministrei um mini curso de django. Então estou disponibilizando tanto os arquivos_mini_curso desenvolvido durante o curso, como os slides. Mini curso introdutório ao DjangoView more presentations from vbmendes.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/04/26/arquivos-do-mini-curso-de-django-disponibilizados/' addthis:title='Arquivos do Mini curso de Django disponibilizados '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>No dia 24 de abril de 2009, no SENAC em Natal/RN, ocorreu o FLISOL. Neste evento, eu ministrei um mini curso de django. Então estou disponibilizando tanto os <a href="http://www.meiocodigo.com/wp-content/uploads/2009/04/arquivos_mini_curso.zip">arquivos_mini_curso</a> desenvolvido durante o curso, como os <a href="http://www.slideshare.net/vbmendes/mini-curso-introdutrio-ao-django-1345709">slides</a>.</p>

<div style="width:425px;text-align:left" id="__ss_1345709"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/vbmendes/mini-curso-introdutrio-ao-django-1345709?type=powerpoint" title="Mini curso introdutório ao Django">Mini curso introdutório ao Django</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mini-curso-slides-090426210203-phpapp01&#038;stripped_title=mini-curso-introdutrio-ao-django-1345709" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mini-curso-slides-090426210203-phpapp01&#038;stripped_title=mini-curso-introdutrio-ao-django-1345709" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/vbmendes">vbmendes</a>.</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2009/04/26/arquivos-do-mini-curso-de-django-disponibilizados/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Festival Latino-americano de Instalação de Software Livre</title>
		<link>http://www.meiocodigo.com/2009/04/24/festival-latino-americano-de-instalacao-de-software-livre/</link>
		<comments>http://www.meiocodigo.com/2009/04/24/festival-latino-americano-de-instalacao-de-software-livre/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 21:58:36 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[flisol]]></category>
		<category><![CDATA[minicurso]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=343</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/04/24/festival-latino-americano-de-instalacao-de-software-livre/' addthis:title='Festival Latino-americano de Instalação de Software Livre '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Venho através deste convidá-los ao FLISOL/RN 2009. O Festival Latino-americano de Instalação de Software Livre do RN irá acontecer no dia 25 de abril de 2009 no SENAC em Natal. No evento eu irei ministrar um mini-curso introdutório ao framework Django das 14:00 as 17:00 horas, cujo objetivo é formar pessoas com conhecimentos básicos acerca [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/04/24/festival-latino-americano-de-instalacao-de-software-livre/' addthis:title='Festival Latino-americano de Instalação de Software Livre '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p><a href="http://rn.softwarelivre.org/flisol/2009/"><img class="alignnone size-full wp-image-342" title="flisol" src="http://www.meiocodigo.com/wp-content/uploads/2009/04/flisol.png" alt="flisol" width="441" height="207" /></a></p>

<p>Venho através deste convidá-los ao <a href="http://rn.softwarelivre.org/flisol/2009/">FLISOL/RN 2009</a>. O Festival Latino-americano de Instalação de Software Livre do RN irá acontecer no dia 25 de abril de 2009 no SENAC em Natal.</p>

<p>No evento eu irei ministrar um mini-curso introdutório ao framework Django das 14:00 as 17:00 horas, cujo objetivo é formar pessoas com conhecimentos básicos acerca do framework. O mini-curso irá abordar diversos conceitos do django através do desenvolvimento de um blog.</p>

<p>Maiores informações sobre o evento podem ser encontradas no <a href="http://rn.softwarelivre.org/flisol/2009/">site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2009/04/24/festival-latino-americano-de-instalacao-de-software-livre/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reffering to Django docs from your docs using Sphinx</title>
		<link>http://www.meiocodigo.com/2009/03/20/reffering-to-django-docs-from-your-docs-using-sphinx/</link>
		<comments>http://www.meiocodigo.com/2009/03/20/reffering-to-django-docs-from-your-docs-using-sphinx/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 15:25:49 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[docs]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=322</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/03/20/reffering-to-django-docs-from-your-docs-using-sphinx/' addthis:title='Reffering to Django docs from your docs using Sphinx '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Sphinx is a great documentation tool, and one of it&#8217;s built-in extensions is sphinx.ext.intersphinx. It simply takes your objects references for other projects and converts to links in the other project&#8217;s documentation. In sphinx-quickstart command, it asks if you want to add this extension. If so, It adds this code to your conf.py file: extensions [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/03/20/reffering-to-django-docs-from-your-docs-using-sphinx/' addthis:title='Reffering to Django docs from your docs using Sphinx '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p><a href="http://sphinx.pocoo.org/">Sphinx</a> is a great documentation tool, and one of it&#8217;s built-in extensions is <a href="http://sphinx.pocoo.org/latest/ext/intersphinx.html">sphinx.ext.intersphinx</a>. It simply takes your objects references for other projects and converts to links in the other project&#8217;s documentation.</p>

<p>In <code>sphinx-quickstart</code> command, it asks if you want to add this extension. If so, It adds this code to your conf.py file:</p>

<p><pre class="brush: python">
extensions = [&#039;sphinx.ext.intersphinx&#039;]
intersphinx_mapping = {&#039;http://docs.python.org/dev&#039;: None}
</pre></p>

<p>As you can see, it comes integrated with python documentation by default. But what I want is to integrate with Django documentation. So I changed the code a little bit:</p>

<p><pre class="brush: python">
extensions = [&#039;sphinx.ext.intersphinx&#039;]
intersphinx_mapping = {
    &#039;http://docs.python.org/dev&#039;: None,
    &#039;http://docs.djangoproject.com/en/dev&#039;: &#039;http://docs.djangoproject.com/en/dev/_objects&#039;,
}
</pre></p>

<p>Sphinx looks for default for the file name objects.inv inside the documentation root, but django doesn&#8217;t provide such a file. Since <a href="http://code.djangoproject.com/ticket/10315">ticket #10315</a> they provided a file like objects.inv but with a different URL: http://docs.djangoproject.com/en/dev/_objects/.</p>

<p>Now, all you have to do is reffer to classe or any kind of objects inside django: <code>:class:<code>django.contrib.auth.models.User</code></code>. It will refference the User documentation inside django&#8217;s docs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2009/03/20/reffering-to-django-docs-from-your-docs-using-sphinx/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Documenting Django pluggable apps with Sphinx</title>
		<link>http://www.meiocodigo.com/2009/03/18/documenting-django-pluggable-apps-with-sphinx/</link>
		<comments>http://www.meiocodigo.com/2009/03/18/documenting-django-pluggable-apps-with-sphinx/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 18:06:46 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[docs]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[pluggable apps]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=317</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/03/18/documenting-django-pluggable-apps-with-sphinx/' addthis:title='Documenting Django pluggable apps with Sphinx '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>I decided to document my Django projects with the same tool used by Django team: Sphinx. It is a very good documenting tool, and was used for many other projects, including the Python Project itself. But it has a simple problem with Django, that I found the solution rlazo&#8217;s blog. But it still has some [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/03/18/documenting-django-pluggable-apps-with-sphinx/' addthis:title='Documenting Django pluggable apps with Sphinx '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I decided to document my Django projects with the same tool used by Django team: <a href="http://sphinx.pocoo.org/">Sphinx</a>. It is a very good documenting tool, and was used for many other projects, including the Python Project itself.</p>

<p>But it has a simple problem with Django, that I found the solution <a href="http://www.rlazo.org/blog/entry/2008/oct/24/documenting-a-django-project-with-sphinx/">rlazo&#8217;s blog</a>. But it still has some problems, when you are trying to document a pluggable app, that doesn&#8217;t have a project, you have to configure the django settings without the project settings, since pluggable apps doesn&#8217;t have a settings module.</p>

<p>Thanks to apollo13, who shown me this better approach, you can simply add this code to sphinx&#8217;s conf.py file:</p>

<p><pre class="brush: python">
from django.conf import settings
settings.configure()
</pre></p>

<p>With this approach, you don&#8217;t need to add any kind of fake files in your project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2009/03/18/documenting-django-pluggable-apps-with-sphinx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MEDIA_URL and context from processors available in HTTP 500 template</title>
		<link>http://www.meiocodigo.com/2009/02/01/media_url-and-context-from-processors-available-in-http-500-template/</link>
		<comments>http://www.meiocodigo.com/2009/02/01/media_url-and-context-from-processors-available-in-http-500-template/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 01:43:58 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[media_url]]></category>
		<category><![CDATA[template context processor]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=285</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/02/01/media_url-and-context-from-processors-available-in-http-500-template/' addthis:title='MEDIA_URL and context from processors available in HTTP 500 template '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>It&#8217;s easy to create a custom template for HTTP 500 errors. All you have to do is create a file named 500.html in any of the application&#8217;s TEMPLATE_DIRS. But in almost all cases you want to use media in this page. It&#8217;s good to have an error page with the same look and feel of [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/02/01/media_url-and-context-from-processors-available-in-http-500-template/' addthis:title='MEDIA_URL and context from processors available in HTTP 500 template '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>It&#8217;s easy to create a custom template for HTTP 500 errors. All you have to do is create a file named 500.html in any of the application&#8217;s TEMPLATE_DIRS. But in almost all cases you want to use media in this page. It&#8217;s good to have an error page with the same look and feel of the system itself.</p>

<p>The default HTTP 500 handler in django uses Context instead of RequestContext. It means that none of your template context processors will be loaded, and the MEDIA_URL variable available in the template system comes exactly from one of these processors. So, without template context processors, we get no MEDIA_URL variable in templates.</p>

<p>Searching in google for a solution to this problem I found a snippet[1] that solves the MEDIA_URL problem. But it still doesn&#8217;t load the processors, all it does is pass the MEDIA_URL variable to the context for template. So I decided to make simple changes in it to load the processors. And here is the complete code:</p>

<p><pre class="brush: python">
def server_error(request, template_name=&#039;500.html&#039;):
    from django.template import RequestContext
    from django.http import HttpResponseServerError
    t = loader.get_template(template_name)
    return HttpResponseServerError(t.render(RequestContext(request)))
</pre></p>

<p>Put this code in any views file you want and then define it as the handler500 in your urls.py:</p>

<p><pre class="brush: python">
handler500 = &#039;views.server_error&#039;
</pre></p>

<p>[1] <a href="http://www.djangosnippets.org/snippets/1199/">http://www.djangosnippets.org/snippets/1199/</a></p>

<p>As <a href="http://chronosbox.org/blog/">Felipe Prenholato</a> mentioned in comments, if you use this code and one of your template context processors raises an Exception it will break badly and will show an ungly HTTP 500 page from your http server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2009/02/01/media_url-and-context-from-processors-available-in-http-500-template/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Django ORM now supports fields references in filters</title>
		<link>http://www.meiocodigo.com/2009/01/29/django-orm-now-supports-fields-references-in-filters/</link>
		<comments>http://www.meiocodigo.com/2009/01/29/django-orm-now-supports-fields-references-in-filters/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 11:28:50 +0000</pubDate>
		<dc:creator>vbmendes</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.meiocodigo.com/?p=281</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/01/29/django-orm-now-supports-fields-references-in-filters/' addthis:title='Django ORM now supports fields references in filters '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Today was added a new feature to django ORM. Now it supports references to fields in filters expressions. Just checkout the SVN version and enjoy it. Before this update, queryset could be filtered only by absolute values. queryset.filter(field=&#039;absolute value&#039;) Will generate somthing like this: SELECT * FROM table_name WHERE field = &#039;absolute value&#039;; Now you [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.meiocodigo.com/2009/01/29/django-orm-now-supports-fields-references-in-filters/' addthis:title='Django ORM now supports fields references in filters '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Today was added a new feature to django ORM. Now it supports references to fields in filters expressions. Just checkout the SVN version and enjoy it.</p>

<p>Before this update, queryset could be filtered only by absolute values.</p>

<p><pre class="brush: python">
queryset.filter(field=&#039;absolute value&#039;)
</pre></p>

<p>Will generate somthing like this:</p>

<p><pre class="brush: sql">
SELECT * FROM table_name WHERE field = &#039;absolute value&#039;;
</pre></p>

<p>Now you can filter by another&#8217;s table field value.</p>

<p><pre class="brush: python">
queryset.filter(field=F(&#039;another_field&#039;))
</pre></p>

<p>Will generate something like this:</p>

<p><pre class="brush: sql">
SELECT * FROM table_name WHERE field = another_field;
</pre></p>

<p>The feature also supports arithmetical operations in the lookups so you can do filters where the views_number is twice as big as the comments_number.</p>

<p><pre class="brush: python">
queryset.filter(views_number__gt=F(&#039;comments_number&#039;)*2)
</pre></p>

<p>Will generate a SQL like this:</p>

<p><pre class="brush: sql">
SELECT * FROM table_name WHERE views_number = comments_number*2;
</pre></p>

<p>It&#8217;s a very good feature. So, checkout the SVN version and take a look at docs/topics/db/queries.txt to know more about this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.meiocodigo.com/2009/01/29/django-orm-now-supports-fields-references-in-filters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

