<?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"
	>
<channel>
	<title>Comments on: Django gotchas - part 1</title>
	<atom:link href="http://monogroncho.com/2008/10/django-gotchas-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://monogroncho.com/2008/10/django-gotchas-part-1/</link>
	<description>Just a collection of random stuff</description>
	<pubDate>Fri, 30 Jul 2010 10:19:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Dynamic select fields with JQuery and django &#171; Formerly Conversal</title>
		<link>http://monogroncho.com/2008/10/django-gotchas-part-1/#comment-14</link>
		<dc:creator>Dynamic select fields with JQuery and django &#171; Formerly Conversal</dc:creator>
		<pubDate>Sun, 01 Nov 2009 17:44:57 +0000</pubDate>
		<guid isPermaLink="false">http://monogroncho.com/?p=91#comment-14</guid>
		<description>[...] This blog post and this blog post set me off in the right direction by showing how to use JQuery&#8217;s getJSON function and how to craft custom fields for the lookup. [...]</description>
		<content:encoded><![CDATA[<p>[...] This blog post and this blog post set me off in the right direction by showing how to use JQuery&#8217;s getJSON function and how to craft custom fields for the lookup. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rok Jaklič</title>
		<link>http://monogroncho.com/2008/10/django-gotchas-part-1/#comment-13</link>
		<dc:creator>Rok Jaklič</dc:creator>
		<pubDate>Wed, 03 Jun 2009 11:49:30 +0000</pubDate>
		<guid isPermaLink="false">http://monogroncho.com/?p=91#comment-13</guid>
		<description>Hi.

I have came up to the similar problem and tried to solve it with like this in forms.py:

    def __init__( self, *args, **kwargs ):
        product_categories = None
        if 'product_categories' in kwargs:
            product_categories = kwargs.pop( 'product_categories' ) 
        super( NewProductForm, self ).__init__( *args, **kwargs )
        if product_categories:
            self.fields["product_category"].widget.choices = product_categories

...where product_category is something like:
product_category = forms.ChoiceField( choices = [], required = False, label = _( 'Product category' ), initial =  'r' )

I almost gave up and was thinking of "manually" creating forms , ... and I really do not understand why this "thingy" did not work when I POSTed data, ... but luckily I have found your solution. 

Thank you.</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>I have came up to the similar problem and tried to solve it with like this in forms.py:</p>
<p>    def __init__( self, *args, **kwargs ):<br />
        product_categories = None<br />
        if &#8216;product_categories&#8217; in kwargs:<br />
            product_categories = kwargs.pop( &#8216;product_categories&#8217; )<br />
        super( NewProductForm, self ).__init__( *args, **kwargs )<br />
        if product_categories:<br />
            self.fields["product_category"].widget.choices = product_categories</p>
<p>&#8230;where product_category is something like:<br />
product_category = forms.ChoiceField( choices = [], required = False, label = _( &#8216;Product category&#8217; ), initial =  &#8216;r&#8217; )</p>
<p>I almost gave up and was thinking of &#8220;manually&#8221; creating forms , &#8230; and I really do not understand why this &#8220;thingy&#8221; did not work when I POSTed data, &#8230; but luckily I have found your solution. </p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Old enough to know better &#187; Dynamic select fields with JQuery and django</title>
		<link>http://monogroncho.com/2008/10/django-gotchas-part-1/#comment-12</link>
		<dc:creator>Old enough to know better &#187; Dynamic select fields with JQuery and django</dc:creator>
		<pubDate>Tue, 19 May 2009 13:43:17 +0000</pubDate>
		<guid isPermaLink="false">http://monogroncho.com/?p=91#comment-12</guid>
		<description>[...] This blog post and this blog post set me off in the right direction by showing how to use JQuery&#8217;s getJSON function and how to craft custom fields for the lookup. [...]</description>
		<content:encoded><![CDATA[<p>[...] This blog post and this blog post set me off in the right direction by showing how to use JQuery&#8217;s getJSON function and how to craft custom fields for the lookup. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ulises</title>
		<link>http://monogroncho.com/2008/10/django-gotchas-part-1/#comment-5</link>
		<dc:creator>Ulises</dc:creator>
		<pubDate>Tue, 04 Nov 2008 14:38:31 +0000</pubDate>
		<guid isPermaLink="false">http://monogroncho.com/?p=91#comment-5</guid>
		<description>@Alexandre

Things I would do to debug the problem:
1) use a browser and try /ajax_load/number_here/ and see that I actually get the json response back
2) use firebug and look at the requests (if you're not already doing that)
3) check that field ids match those you use in your javascript code
4) careful with character escaping (in your template you have a &#60; instead of &lt;) and finally
5) go to #django in freenode and ask as people there are really friendly and helpful

Hope that helps.</description>
		<content:encoded><![CDATA[<p>@Alexandre</p>
<p>Things I would do to debug the problem:<br />
1) use a browser and try /ajax_load/number_here/ and see that I actually get the json response back<br />
2) use firebug and look at the requests (if you&#8217;re not already doing that)<br />
3) check that field ids match those you use in your javascript code<br />
4) careful with character escaping (in your template you have a &lt; instead of <) and finally<br />
5) go to #django in freenode and ask as people there are really friendly and helpful</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexandre</title>
		<link>http://monogroncho.com/2008/10/django-gotchas-part-1/#comment-4</link>
		<dc:creator>Alexandre</dc:creator>
		<pubDate>Tue, 04 Nov 2008 14:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://monogroncho.com/?p=91#comment-4</guid>
		<description>Hi, i'm having problems with you example, nothing happens with the second choice field on the change event of the first one...

Maybe i'm doing something wrong:

1) i placed this inside urls.py
(r'^myview/$', 'Representantes.dynamic_choice.views.myview'),
(r'^ajax_load/(\d+)/$', 'Representantes.dynamic_choice.views.get_2ndCF_values_json'),

2) my template "myform.html" looks like this:
http://dpaste.com/hold/88658/

Thanks</description>
		<content:encoded><![CDATA[<p>Hi, i&#8217;m having problems with you example, nothing happens with the second choice field on the change event of the first one&#8230;</p>
<p>Maybe i&#8217;m doing something wrong:</p>
<p>1) i placed this inside urls.py<br />
(r&#8217;^myview/$&#8217;, &#8216;Representantes.dynamic_choice.views.myview&#8217;),<br />
(r&#8217;^ajax_load/(\d+)/$&#8217;, &#8216;Representantes.dynamic_choice.views.get_2ndCF_values_json&#8217;),</p>
<p>2) my template &#8220;myform.html&#8221; looks like this:<br />
<a href="http://dpaste.com/hold/88658/" rel="nofollow">http://dpaste.com/hold/88658/</a></p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Claudiu</title>
		<link>http://monogroncho.com/2008/10/django-gotchas-part-1/#comment-3</link>
		<dc:creator>Claudiu</dc:creator>
		<pubDate>Thu, 09 Oct 2008 09:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://monogroncho.com/?p=91#comment-3</guid>
		<description>Indeed, very useful information. Thanks!</description>
		<content:encoded><![CDATA[<p>Indeed, very useful information. Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
