<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Adventures in Django and Python &#8211; Part III</title>
	<atom:link href="http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Fri, 12 Mar 2010 21:11:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andrew Shultz</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2739</link>
		<dc:creator>Andrew Shultz</dc:creator>
		<pubDate>Tue, 18 Aug 2009 02:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2739</guid>
		<description>You could do something crazy like subclass the form and give it special processing that will munge some of the fields in ways you approve of.  We did that back on 0.96 to use the automatic model form fields but have some of them hidden (there was no &quot;uneditable&quot; then) or to be able to set the entire form to be uneditable.&lt;br&gt;&lt;br&gt;In the process I hacked up the automatic form generation a fair bit - unfortunately not all the required pieces were exposed by newforms at the time, which was very irritating since I don&#039;t expect to have python modules have functions I&#039;m not allowed to get to somehow.  I expect many of the specifics have changed but the basic idea might still work, though not cleanly.</description>
		<content:encoded><![CDATA[<p>You could do something crazy like subclass the form and give it special processing that will munge some of the fields in ways you approve of.  We did that back on 0.96 to use the automatic model form fields but have some of them hidden (there was no &#8220;uneditable&#8221; then) or to be able to set the entire form to be uneditable.</p>
<p>In the process I hacked up the automatic form generation a fair bit &#8211; unfortunately not all the required pieces were exposed by newforms at the time, which was very irritating since I don&#39;t expect to have python modules have functions I&#39;m not allowed to get to somehow.  I expect many of the specifics have changed but the basic idea might still work, though not cleanly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Shultz</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2680</link>
		<dc:creator>Andrew Shultz</dc:creator>
		<pubDate>Mon, 17 Aug 2009 22:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2680</guid>
		<description>You could do something crazy like subclass the form and give it special processing that will munge some of the fields in ways you approve of.  We did that back on 0.96 to use the automatic model form fields but have some of them hidden (there was no &quot;uneditable&quot; then) or to be able to set the entire form to be uneditable.&lt;br&gt;&lt;br&gt;In the process I hacked up the automatic form generation a fair bit - unfortunately not all the required pieces were exposed by newforms at the time, which was very irritating since I don&#039;t expect to have python modules have functions I&#039;m not allowed to get to somehow.  I expect many of the specifics have changed but the basic idea might still work, though not cleanly.</description>
		<content:encoded><![CDATA[<p>You could do something crazy like subclass the form and give it special processing that will munge some of the fields in ways you approve of.  We did that back on 0.96 to use the automatic model form fields but have some of them hidden (there was no &#8220;uneditable&#8221; then) or to be able to set the entire form to be uneditable.</p>
<p>In the process I hacked up the automatic form generation a fair bit &#8211; unfortunately not all the required pieces were exposed by newforms at the time, which was very irritating since I don&#39;t expect to have python modules have functions I&#39;m not allowed to get to somehow.  I expect many of the specifics have changed but the basic idea might still work, though not cleanly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Buchanan</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2676</link>
		<dc:creator>Jonathan Buchanan</dc:creator>
		<pubDate>Fri, 14 Aug 2009 17:49:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2676</guid>
		<description>In addition to letting you easily generate HTML4 from your forms (slash, begone!), the &quot;field&quot; template tag provided by &lt;a href=&quot;http://github.com/simonw/django-html/&quot; rel=&quot;nofollow&quot;&gt;http://github.com/simonw/django-html/&lt;/a&gt; lets you specify attributes for rendered form fields:&lt;br&gt;&lt;br&gt;{% field form.somefield class=&quot;special&quot; %}</description>
		<content:encoded><![CDATA[<p>In addition to letting you easily generate HTML4 from your forms (slash, begone!), the &#8220;field&#8221; template tag provided by <a href="http://github.com/simonw/django-html/" rel="nofollow">http://github.com/simonw/django-html/</a> lets you specify attributes for rendered form fields:</p>
<p>{% field form.somefield class=&#8221;special&#8221; %}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matticakes</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2675</link>
		<dc:creator>matticakes</dc:creator>
		<pubDate>Fri, 14 Aug 2009 14:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2675</guid>
		<description>You have to define those attributes somewhere.  It makes more sense (to me) to do that within the template than in your form definition or in your view.&lt;br&gt;&lt;br&gt;Even if you ultimately style the attributes using CSS you have to specify that class somewhere.  I&#039;d like to able to easily do that from within the template.</description>
		<content:encoded><![CDATA[<p>You have to define those attributes somewhere.  It makes more sense (to me) to do that within the template than in your form definition or in your view.</p>
<p>Even if you ultimately style the attributes using CSS you have to specify that class somewhere.  I&#39;d like to able to easily do that from within the template.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andybak</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2674</link>
		<dc:creator>andybak</dc:creator>
		<pubDate>Fri, 14 Aug 2009 10:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2674</guid>
		<description>Shouldn&#039;t those attributes be defined in CSS? Then it&#039;s not quite so unappealing to simply use attrs to modify or append to the class name (even this might not be needed - you can use the id assigned to each form element or just use CSS attribute selectors)</description>
		<content:encoded><![CDATA[<p>Shouldn&#39;t those attributes be defined in CSS? Then it&#39;s not quite so unappealing to simply use attrs to modify or append to the class name (even this might not be needed &#8211; you can use the id assigned to each form element or just use CSS attribute selectors)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matticakes</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2673</link>
		<dc:creator>matticakes</dc:creator>
		<pubDate>Thu, 13 Aug 2009 20:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2673</guid>
		<description>try the &lt;pre&gt; HTML tag&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;@register.filter&lt;br&gt;def with_attrs(value, arg):&lt;br&gt;	attrs = {}&lt;br&gt;	for x in arg.split(&#039;,&#039;):&lt;br&gt;		v = x.strip().split(&#039;=&#039;)&lt;br&gt;		attrs[v[0]] = v[1]&lt;br&gt;&lt;br&gt;	return value.as_widget(attrs=attrs)&lt;br&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>try the &lt;pre&gt; HTML tag</p>
<p>&lt;pre&gt;<br />@register.filter<br />def with_attrs(value, arg):<br />	attrs = {}<br />	for x in arg.split(&#39;,&#39;):<br />		v = x.strip().split(&#39;=&#39;)<br />		attrs[v[0]] = v[1]</p>
<p>	return value.as_widget(attrs=attrs)<br />&lt;/pre&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2672</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 13 Aug 2009 20:00:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2672</guid>
		<description>A quick look at BoundField and it does not appear the chaining of attrs would work.  Maybe a comma: (how do you make this thing keep formatting?)&lt;br&gt;&lt;br&gt;@register.filter&lt;br&gt;def with_attrs(value, arg):&lt;br&gt;    attrs = {}&lt;br&gt;    for x in arg.split(&#039;,&#039;):&lt;br&gt;        v = x.strip().split(&#039;=&#039;)&lt;br&gt;        attrs[v[0]] = v[1]&lt;br&gt;&lt;br&gt;    return value.as_widget(attrs=attrs)</description>
		<content:encoded><![CDATA[<p>A quick look at BoundField and it does not appear the chaining of attrs would work.  Maybe a comma: (how do you make this thing keep formatting?)</p>
<p>@register.filter<br />def with_attrs(value, arg):<br />    attrs = {}<br />    for x in arg.split(&#39;,&#39;):<br />        v = x.strip().split(&#39;=&#39;)<br />        attrs[v[0]] = v[1]</p>
<p>    return value.as_widget(attrs=attrs)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2671</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 13 Aug 2009 19:28:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2671</guid>
		<description>Yea,  like i said this had been floating around for a while..  Space was just the first thing that jumped out at me.  Of course that does not work for style stuff.&lt;br&gt;&lt;br&gt;might be better to write it so it can be chained:&lt;br&gt;&lt;br&gt;{{ form.name&#124;with_attrs:&quot;size=10&quot;&#124;with_attrs:&quot;style: width: 720px&quot; }}</description>
		<content:encoded><![CDATA[<p>Yea,  like i said this had been floating around for a while..  Space was just the first thing that jumped out at me.  Of course that does not work for style stuff.</p>
<p>might be better to write it so it can be chained:</p>
<p>{{ form.name|with_attrs:&#8221;size=10&#8243;|with_attrs:&#8221;style: width: 720px&#8221; }}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matticakes</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2670</link>
		<dc:creator>matticakes</dc:creator>
		<pubDate>Thu, 13 Aug 2009 19:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2670</guid>
		<description>I looked up the &#039;attrs&#039; documentation, which is sparse.  I don&#039;t think it&#039;s the responsibility of the view or the Form definition to define template related attributes like style, size, etc.  I think these attributes should elegantly be modified within the template.</description>
		<content:encoded><![CDATA[<p>I looked up the &#39;attrs&#39; documentation, which is sparse.  I don&#39;t think it&#39;s the responsibility of the view or the Form definition to define template related attributes like style, size, etc.  I think these attributes should elegantly be modified within the template.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matticakes</title>
		<link>http://blog.perplexedlabs.com/2009/08/13/adventures-in-django-and-python-part-iii/comment-page-1/#comment-2669</link>
		<dc:creator>matticakes</dc:creator>
		<pubDate>Thu, 13 Aug 2009 19:20:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/?p=307#comment-2669</guid>
		<description>John, this is exactly in line with what I&#039;d like to be able to accomplish.  I like where you&#039;re going with this.&lt;br&gt;&lt;br&gt;Perhaps splitting on something other than a space?</description>
		<content:encoded><![CDATA[<p>John, this is exactly in line with what I&#39;d like to be able to accomplish.  I like where you&#39;re going with this.</p>
<p>Perhaps splitting on something other than a space?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
