<?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>zoia.org &#187; Fotografia</title>
	<atom:link href="http://www.zoia.org/blog/category/fotografia/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zoia.org/blog</link>
	<description>Por Roberto Zoia</description>
	<lastBuildDate>Fri, 18 Jun 2010 14:04:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fotos de Blair Bunting</title>
		<link>http://www.zoia.org/blog/2008/07/16/fotos-de-blair-bunting/</link>
		<comments>http://www.zoia.org/blog/2008/07/16/fotos-de-blair-bunting/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 18:12:09 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[blair_bunting]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[strobist]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/?p=248</guid>
		<description><![CDATA[A raíz del artículo que escribe Strobist sobre iluminación de retratos, encontré la galería de fotos de Blair Bunting. Muy buena.]]></description>
			<content:encoded><![CDATA[<p>A raíz del artículo que escribe <a href="http://strobist.blogspot.com/2008/07/rembrandt-lighting-um-no.html">Strobist</a> sobre iluminación de retratos, encontré la galería de fotos de <a href="http://www.blairbunting.com">Blair Bunting</a>. Muy buena.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2008/07/16/fotos-de-blair-bunting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joe McNally en Google Talks</title>
		<link>http://www.zoia.org/blog/2008/05/25/joe-mcnally-en-google-talks/</link>
		<comments>http://www.zoia.org/blog/2008/05/25/joe-mcnally-en-google-talks/#comments</comments>
		<pubDate>Sun, 25 May 2008 17:43:25 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[joe_mcnally]]></category>
		<category><![CDATA[photgraphy]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/?p=231</guid>
		<description><![CDATA[Joe McNally es un fotógrafo profesional de bastante trayectoria. Ha sido años fotografo de National Geographic y otros medios importantes. Gracias a su blog se pueden aprender algunos tips fotográficos interesantes pues, como él mismo dice, no es de esos fotógrafos que conservan sus técnicas en secreto, como si eso fuera parte de su éxito. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Joe_McNally">Joe McNally</a> es un fotógrafo profesional de bastante trayectoria.  Ha sido años fotografo de National Geographic y otros medios importantes.</p>

<p>Gracias a su  <a href="http://www.joemcnally.com/blog/">blog</a> se pueden aprender algunos tips fotográficos interesantes pues, como él mismo dice, no es de esos fotógrafos que conservan sus técnicas en secreto, como si eso fuera parte de su éxito.  Por ejemplo, abajo pueden ver un video sencillo de su <a href="http://www.youtube.com/joemcnallyphoto">canal de YouTube</a> sobre sus técnicas para agarrar la cámara de fotos.</p>

<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/EDsx3-FWfwk&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/EDsx3-FWfwk&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>

<p>También tiene una pagina con su <a href="http://joemcnally.com">portafolio</a>, donde se pueden ver algunos de los proyectos en los que ha trabajado.</p>

<p>A través de <a href="http://strobist.blogspot.com">Strobist</a> me enteré de esta presentación que dio en Google, y que está en el canal de Google Talks en YouTube. Recomendada. (Dura algo más de una hora, está en inglés.)</p>

<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/1Av6gCq_awQ&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/1Av6gCq_awQ&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2008/05/25/joe-mcnally-en-google-talks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Una buena galería de fotos y tutorials de Photoshop</title>
		<link>http://www.zoia.org/blog/2008/05/11/una-buena-galeria-de-fotos-y-tutorials-de-photoshop/</link>
		<comments>http://www.zoia.org/blog/2008/05/11/una-buena-galeria-de-fotos-y-tutorials-de-photoshop/#comments</comments>
		<pubDate>Sun, 11 May 2008 22:38:46 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[fotos]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/2008/05/11/una-buena-galeria-de-fotos-y-tutorials-de-photoshop/</guid>
		<description><![CDATA[Leyendo Greetings from the Land of Cranes en el blog de Strobist descubrí Chromasia, el website de David Nightingale.Tiene una galería de fotos que impresiona. También tiene una sección de tutorials de Photoshop. Para verlos hay que pagar (no son demasiado caros), y hay uno de muestra sobre curvas de color. Quizá lo más saltante [...]]]></description>
			<content:encoded><![CDATA[<p>Leyendo <a href="http://strobist.blogspot.com/2008/04/greetings-from-land-of-cranes.html">Greetings from the Land of Cranes</a> en el blog de Strobist descubrí <a href="http://www.chromasia.com">Chromasia</a>,  el website de David Nightingale.<br /><br />Tiene una <a href="http://www.chromasia.com/galleries/">galería de fotos</a> que impresiona. También tiene una sección de <a href="http://www.chromasia.com/tutorials/online">tutorials</a> de Photoshop. Para verlos hay que pagar (no son demasiado caros), y hay uno de muestra sobre curvas de color.  Quizá lo más saltante es que a diferencia de otros tutorials que he visto por ahí, éste no sólo se limita a decir qué diálogos abrir y qué botonos presionar sino que <em>explica por qué</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2008/05/11/una-buena-galeria-de-fotos-y-tutorials-de-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hackeando una Canon PowerShot</title>
		<link>http://www.zoia.org/blog/2008/05/07/hackeando-una-canon-powershot/</link>
		<comments>http://www.zoia.org/blog/2008/05/07/hackeando-una-canon-powershot/#comments</comments>
		<pubDate>Wed, 07 May 2008 15:42:49 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[bracketing]]></category>
		<category><![CDATA[canon]]></category>
		<category><![CDATA[chdk]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[powershot]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/?p=221</guid>
		<description><![CDATA[Via Lifehacker me enteré del Canon Hacker&#8217;s Development Kit (CHDK). Se trata de unas modificaciones al software de la cámara de fotos (una cámara de fotos digital es finalmente una computadora especializada, con su sistema operativo y todo) que abre posibilidades que sólo se encuentran en modelos superiores, o permiten ajustar al gusto algunos parámetros. [...]]]></description>
			<content:encoded><![CDATA[<p>Via <a href="http://lifehacker.com/387380/turn-your-point+and+shoot-into-a-super+camera">Lifehacker</a> me enteré del <a href="http://chdk.wikia.com/wiki/CHDK">Canon Hacker&#8217;s Development Kit</a> (CHDK).  Se trata de unas modificaciones al <em>software</em> de la cámara de fotos (una cámara de fotos digital es finalmente una computadora especializada, con su sistema operativo y todo) que abre posibilidades que sólo se encuentran en modelos superiores, o permiten ajustar al gusto algunos parámetros.</p>

<p>Mi experiencia con las Canon PowerShot es que toman fotos excelentes para las necesidades del común de los mortales. (Ver, por ejemplo, la foto de abajo, que aunque no la tomé yo está tomada con una PowerShot) Estos <em>hacks</em> no van a sustituir un buen encuadre ni la creatividad del fotógrafo: si tus fotos son malas, seguirán siendo malas. Pero añaden algunas herramientas útiles al kit.</p>

<div>
<a href="http://farm3.static.flickr.com/2219/2370911287_1f83845364_b_d.jpg" alt="Una ca&iacute;da de agua camino a Tupe" rel="lightbox"><img src="http://farm3.static.flickr.com/2219/2370911287_1f83845364_d.jpg" title="Una ca&iacute;da de agua camino a Tupe" /></a></div>

<div style="clear: both"> </div>

<p><br /></p>

<h2>Puntos a favor para animarse a probar este &#8220;hack&#8221;</h2>

<ul>
<li>La instalación es muy sencilla:  se copian unos archivos al SD Card, se enciende la cámara y ¡listo!</li>
<li>Los cambios no son permanentes, son totalmente reversibles.  ¿No funcionan bien, o quiero quitarlos?  Igual de sencillo:  se apaga la cámara, se borran los archivos del SD Card. ¡Listo! A diferencia de los <a href="http://web.canon.jp/imaging/BeBit-e.html">parches oficiales de Canon</a>, el CHDK no modifica permanentemente la cámara.</li>
</ul>

<h2>¿Qué funcionalidades añade el hack a la cámara?</h2>

<ul>
<li>Permite guardar imágenes en formato RAW. Las PowerShot guardan las fotos en formato JPG.  Las fotos ocupan menos espacio, pero se pierde parte de la información al comprimir. Para muchos usos este formato basta.  Pero si queremos modificar la imagen con algún programa de edición digital, o hacer una impresión de calidad, el formato RAW da mejores resultados.</li>
<li>Muestra información adicional en la pantalla.</li>
<li>Funciones adicionales como <em>bracketing</em> automático.  ¿Qué es <em>bracketing</em>?  Supongamos que queremos tomar una foto fijando manualmente la apertura del lente (Av).  La velocidad puede fijarla automáticamente la cámara, o podemos fijarla nosotros manualmente.  Cuando el <em>bracketing</em> está activado y apretamos el disparador, la cámara toma varias fotos seguidas:  una, a la apertura que hemos especificado;  otras, con unos puntos más de apertura;  y otras, con un puntos menos.  Esto permite escoger la foto con la apertura óptima, que no siempre es la que determina automáticamente la cámara.</li>
<li>Bien interesante, el CHDK permite escribir programas sencillos (scripts) en una especie de BASIC y cargarlos a la cámara.  Aquí algunos ejemplos:  <a href="http://chdk.wikia.com/wiki/UBASIC/Scripts">http://chdk.wikia.com/wiki/UBASIC/Scripts</a>.  Hay varios de <em>OMNI-bracketing</em>, es decir, hacer <em>bracketing</em> no sólo con la apertura, sino variando la velocidad e incluso el ISO. (Espero que no empiecen a aparecer virus para cámaras de fotos&#8230;)</li>
</ul>

<p>No he podido probar el parche personalmente, porque la PowerShot a la que tengo acceso es una A90 y no está en la lista de <a href="http://chdk.wikia.com/wiki/FAQ#Q._What_camera_models_are_supported_by_the_CHDK_program.3F">cámaras que funcionan con CHDK</a> Pero las instrucciones de Lifehacker (ver link arriba) son bastante claras.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2008/05/07/hackeando-una-canon-powershot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flor de Amancaes</title>
		<link>http://www.zoia.org/blog/2008/04/19/flor-de-amancaes/</link>
		<comments>http://www.zoia.org/blog/2008/04/19/flor-de-amancaes/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 15:08:17 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[canon_lens]]></category>
		<category><![CDATA[flor_de_amancaes]]></category>
		<category><![CDATA[Lima]]></category>
		<category><![CDATA[peru]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/?p=205</guid>
		<description><![CDATA[Una foto que tomé de una flor de amancaes. El lente es un Canon 17-85mm USM con estabilizador de imagen (IS). El encuadre no es el mejor, pero la posición no era tan fácil, y la idea era tomar la foto donde estaba. No tiene retoque digital, sólo la he recortado a 1280&#215;1024. (click en [...]]]></description>
			<content:encoded><![CDATA[<p>Una foto que tomé de una flor de amancaes.  El lente es un Canon 17-85mm USM con estabilizador de imagen (IS).  El encuadre no es el mejor, pero la posición no era tan fácil, y la idea era tomar la foto donde estaba.  No tiene retoque digital, sólo la he recortado a 1280&#215;1024.</p>

<p><a href='http://www.zoia.org/blog/wp-content/uploads/2008/04/flordeamancaes_1280x1024.jpg'><img src="http://www.zoia.org/blog/wp-content/uploads/2008/04/flordeamancaes_1280x1024_thumb.jpg" alt="Flor de Amancaes" title="Flor de Amancaes"  /></a></p>

<p>(click en la imagen para verla a 1280&#215;1024)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2008/04/19/flor-de-amancaes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fotografía de Yann Arthus-Bertrand en Lima</title>
		<link>http://www.zoia.org/blog/2008/04/14/fotografia-de-yann-arthus-bertrand-en-lima/</link>
		<comments>http://www.zoia.org/blog/2008/04/14/fotografia-de-yann-arthus-bertrand-en-lima/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 14:12:37 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[yann arthus-bertrand]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/?p=198</guid>
		<description><![CDATA[Hace unas semanas publiqué un link a las geniales fotografías de Yann Arthus-Bertrand. Pues bien, mañana 15 de abril a las 6 p.m. se inaugura una exposición de sus fotos en el Parque de Miraflores, Pasaje los Pintores. Se trata de una exposición itinerante que ya ha estado por bastantes países. (Via El Comercio)]]></description>
			<content:encoded><![CDATA[<p>Hace unas semanas <a href="http://www.zoia.org/blog/2007/12/13/mas-fotos-muy-buenas/">publiqué un link</a> a las geniales fotografías de <a href="http://www.yannarthusbertrand.fr/">Yann Arthus-Bertrand</a>.</p>

<p>Pues bien, mañana 15 de abril a las 6 p.m. se inaugura una exposición de sus fotos en el Parque de Miraflores, Pasaje los Pintores.  Se trata de una exposición itinerante que ya ha estado por bastantes países.  (Via <a href="http://www.elcomercioperu.com.pe/edicionimpresa/Html/2008-04-06/el-placer-ver-paisajes-excepcionales.html">El Comercio</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2008/04/14/fotografia-de-yann-arthus-bertrand-en-lima/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Más fotos muy buenas</title>
		<link>http://www.zoia.org/blog/2007/12/13/mas-fotos-muy-buenas/</link>
		<comments>http://www.zoia.org/blog/2007/12/13/mas-fotos-muy-buenas/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 20:30:05 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/2007/12/13/mas-fotos-muy-buenas/</guid>
		<description><![CDATA[Leyendo el blog de Google encontré esta página web con muy buenas fotos: Yann Arthus-Bertrand. Hay buenas fotos aereas. (Por si acaso tienen copyright, no están bajo licencia Creative Commons.).]]></description>
			<content:encoded><![CDATA[<p>Leyendo el <a href="http://googleblog.blogspot.com/2007/12/earth-from-above.html">blog de Google</a> encontré esta página web con muy buenas fotos:  <a href="http://www.yannarthusbertrand.fr/">Yann Arthus-Bertrand</a>.  Hay buenas fotos aereas. (Por si acaso tienen copyright, no están bajo licencia Creative Commons.).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2007/12/13/mas-fotos-muy-buenas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fotos impresionantes y cómo se tomaron</title>
		<link>http://www.zoia.org/blog/2007/12/08/fotos-impresionantes-y-como-se-tomaron/</link>
		<comments>http://www.zoia.org/blog/2007/12/08/fotos-impresionantes-y-como-se-tomaron/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 00:07:15 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[Fotografia]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/2007/12/08/fotos-impresionantes-y-como-se-tomaron/</guid>
		<description><![CDATA[En Stunning Nikon se pueden ver algunas fotos impresionates del Nikon-Pro Challenge. Y en Strobist explica cómo tomó James Balog las de los icebergs. Lamentablemente no puedo reproducir las fotos aquí&#8230;]]></description>
			<content:encoded><![CDATA[<p>En <a href="http://www.stunningnikon.com/challenge/">Stunning Nikon</a> se pueden ver algunas fotos impresionates del Nikon-Pro Challenge.  Y en <a href="http://strobist.blogspot.com/2007/12/assisting-on-james-balog-iceberg-shoot.html">Strobist</a> explica cómo tomó <a href="http://strobist.blogspot.com/2007/12/assisting-on-james-balog-iceberg-shoot.html">James Balog</a> las de los <em>icebergs</em>.  Lamentablemente no puedo reproducir las fotos aquí&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2007/12/08/fotos-impresionantes-y-como-se-tomaron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iterating over items of selection fields in django templates using newforms</title>
		<link>http://www.zoia.org/blog/2007/03/24/iterating-over-items-of-selection-fields-in-django-templates-using-newforms/</link>
		<comments>http://www.zoia.org/blog/2007/03/24/iterating-over-items-of-selection-fields-in-django-templates-using-newforms/#comments</comments>
		<pubDate>Sat, 24 Mar 2007 16:28:33 +0000</pubDate>
		<dc:creator>Roberto</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Fotografia]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.zoia.org/blog/2007/03/24/iterating-over-items-of-selection-fields-in-django-templates-using-newforms/</guid>
		<description><![CDATA[A year ago I wrote a custom CheckboxSelectMultiple control for django. My application needed to display a series of checkboxes on the webpage, but the default django control did not allow iteration over each checkbox when the control was rendered in the template (as it was possible with the RadioSelect control). This finer control was [...]]]></description>
			<content:encoded><![CDATA[<p>A year ago I wrote a <a href="http://www.zoia.org/blog/2006/02/22/django-and-custom-checkboxselectmultiplefield/">custom CheckboxSelectMultiple</a> control for <a href="http://www.djangoproject.com">django</a>.  My application needed to display a series of checkboxes on the webpage, but the default django control did not allow iteration over each checkbox when the control was rendered in the template (as it was possible with the RadioSelect control).  This finer control was necessary because I needed to insert extra HTML between each checkbox.</p>

<p>As of version 0.95, django has been under heavy changes, and my custom control no longer works.  In particular, the old forms module is being discarded in favor of the newforms module that will become the default forms module sometime in the future.  A good explanation can be found in the on-site django documentation, under <a href="http://www.djangoproject.com/documentation/newforms/#migration-plan">newforms-migration plan</a>.</p>

<p>The good news is that newforms allows access to individual items of the form fields, multiple-select fields included. The newforms documentation is still work in progress, so it took me a while to figure out how to do it&#8230; by inspecting the source code and regression tests. It seems pretty obvious now, should have asked in the <a href="http://groups.google.com/group/django-users">django-users list</a>.</p>

<p>The example code has been tested with django svn release 4812 (2007-3-23).</p>

<p><strong><span style="text-decoration: underline;">2007-03-27</span></strong>: By mistake I published an incorrect version of <code>views.py</code>.  Code has been corrected so that now   <code>add_post</code> saves the tag field as expected. <span style="text-decoration: line-through;">(<code>Post</code> has a many-to-many relationship with <code>Tag</code>, so <code>form.save()</code> is not enough to save the form data.)</span></p>

<p><strong><span style="text-decoration: underline;">2007-04-12</span></strong>:  The code for <code>views.py</code> has been corrected again.  The code posted 2007-03-27 works, but as I discovered later, there is no need to create another object (<code>p = Post(**cleandata)</code>) to handle the many-to-many field data.  <code>form.save()</code> takes care of everything, as expected.</p>

<p><strong><span style="text-decoration: underline;">2007-04-24</span></strong>:  You may be interested in <a href="http://www.zoia.org/blog/2007/04/23/using-dynamic-choices-with-django-newforms-and-custom-widgets/">this post</a>.</p>

<h2>template</h2>

<p><pre>
</pre><pre class="brush: xml;">&lt;/p&gt;

&lt;ul&gt;
{% for choice in form.base_fields.tag.choices %}
&lt;li&gt; ({{ choice.0 }}, {{ choice.1 }}) &lt;/li&gt;
{% endfor %}
&lt;/ul&gt;

&lt;p&gt;</pre>
</p>

<h2>models.py</h2>

<p><pre>
</pre><pre class="brush: python;">&lt;/p&gt;

&lt;h1&gt;-&lt;em&gt;- coding: utf-8 -&lt;/em&gt;-&lt;/h1&gt;

&lt;h1&gt;models.py&lt;/h1&gt;

&lt;p&gt;from django.db import models&lt;/p&gt;

&lt;p&gt;class Tag(models.Model):
    tag = models.CharField(maxlength=20)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def __str__(self):
    return self.tag
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;class Post(models.Model):
    # other fields here:
    # text = models.CharField(maxlength=255)
    # title = models.CharField(maxlength=50)
    # etc.
    tag = models.ManyToManyField(Tag)&lt;/p&gt;

&lt;p&gt;</pre>
</p>

<h2>views.py</h2>

<p><pre>
</pre><pre class="brush: python;">&lt;/p&gt;

&lt;h1&gt;-&lt;em&gt;- coding: utf-8 -&lt;/em&gt;-&lt;/h1&gt;

&lt;h1&gt;views.py&lt;/h1&gt;

&lt;p&gt;from django.template import Context, loader
from django.http import HttpResponse, HttpResponseRedirect&lt;/p&gt;

&lt;p&gt;from django import newforms as forms
from django.newforms.widgets import *&lt;/p&gt;

&lt;p&gt;from project.models import *&lt;/p&gt;

&lt;p&gt;def add_post(request):
    postForm = forms.models.form_for_model(Post)
    if request.method == 'POST':
       form = postForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(&quot;/&quot;)
    else:
         form = postForm()
         t = loader.get_template('add_post.html')
         c = Context({
               'form': form,
               })&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;     return HttpResponse(t.render(c))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;</pre>
</p>

<h2><span style="text-decoration: line-through;">views.py</span></h2>

<p>This is an old version of <code>views.py</code>.  The code works, but as I discovered later, there is no need to create another object (<code>p = Post(**cleandata)</code>) to handle the many-to-many field data.  form.save() takes care of everything, as expected.
<pre>
</pre><pre class="brush: python;">&lt;/p&gt;

&lt;h1&gt;-&lt;em&gt;- coding: utf-8 -&lt;/em&gt;-&lt;/h1&gt;

&lt;h1&gt;views.py&lt;/h1&gt;

&lt;p&gt;from django.template import Context, loader
from django.http import HttpResponse, HttpResponseRedirect&lt;/p&gt;

&lt;p&gt;from django import newforms as forms
from django.newforms.widgets import *&lt;/p&gt;

&lt;p&gt;from project.models import *&lt;/p&gt;

&lt;p&gt;def add_post(request):
    postForm = forms.models.form_for_model(Post)
    if request.method == 'POST':
        form = postForm(request.POST)
        if form.is_valid():
           cleandata = form.clean_data
           # use the form tag ids to select the Tag instances
           # related to this Post entry
           tag = Tag.objects.in_bulk(cleandata['tag'])
           # need to delete the tag ids from clean data,
           # otherwise p = Post(** cleandata) will complain that
           # tag is not a parameter of Post( )
           del cleandata['tag']&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;       # create an instance of Post from the form data
       p = Post(**cleandata)
       p.save()   # need to save so p gets an id.
       p.tag = tag
       p.save()

       return HttpResponseRedirect(&amp;amp;amp;quot;/&amp;amp;amp;quot;)
   else:
   form = postForm()

   t = loader.get_template('add_post.html')
   c = Context({
          'form': form,
    })

    return HttpResponse(t.render(c))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;</pre>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zoia.org/blog/2007/03/24/iterating-over-items-of-selection-fields-in-django-templates-using-newforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
