<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6696643292414056209</id><updated>2024-09-05T16:41:28.223+02:00</updated><category term="django"/><category term="python"/><title type='text'>FerMenta</title><subtitle type='html'>fresh geek air for everyone ;)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://fer-menta.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6696643292414056209/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://fer-menta.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>marco</name><uri>http://www.blogger.com/profile/02488000778953844299</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSFC4OUYMFeczpiCLcbav4k_JMBbWYfEAyrva_Fy6DVuJ-oymHkkDujp6OR73WSwdHPI_JI_NjlH7CYnMb6tsP5LDkDd9mf6IREgJJ8L4jtIhzIlv0Y7z7ouPolRDZod4/s220/2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6696643292414056209.post-3599455736820322231</id><published>2010-12-18T16:13:00.001+01:00</published><updated>2010-12-18T16:26:20.994+01:00</updated><title type='text'>jQuery expanding textarea</title><content type='html'>I&#39;ve been using dojo for some time now as my default javascript toolkit. From some days I&#39;m giving a look at jQuery becouse of its popularity. It&#39;s not always true that popular = good but it seems is not this the case. As soon as I started using it I&#39;ve founded it easy, simple and clean. From dojo I often use the dijit TextArea widget. This widget is a nice beast that autoexpand itself to fit the text content inside. No scroll bars will be showed and it is really nice in some context. I&#39;ve googled for a similar widget into the jQuery ecosystem but, to my surprise, I have not found anything equiparable in terms of quality. So in short, I decided to port the dojo one to jQuery.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Example:&lt;/span&gt;&lt;br /&gt;
Here an example (type some lines into the textarea below)&lt;br /&gt;
&lt;br /&gt;
&lt;textarea cols=&quot;40&quot; id=&quot;expanding-textarea-example&quot; rows=&quot;1&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
&lt;script&gt;
$(&#39;#expanding-textarea-example&#39;).expandingTextArea();
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Usage&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;script src=&quot;jquery.min.js&quot; type=&quot;text/javascript&quot;&amp;gt;
&amp;lt;/script&amp;gt;
&amp;lt;script src=&quot;jquery.exptextarea.js&quot; type=&quot;text/javascript&quot;&amp;gt;
&amp;lt;/script&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
Now you can select a text area using jQuery selector and turn it into an expandable one&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;textarea&amp;gt;&amp;lt;/textarea&amp;gt;
&amp;lt;script&amp;gt;
$(&#39;textarea&#39;).expandingTextArea();
&amp;lt;/script&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Download&lt;/span&gt;&lt;br /&gt;
I&#39;ve shared the code with you on github:&lt;br /&gt;
&lt;a href=&quot;https://github.com/ferama/jquery-expanding-textarea/&quot;&gt;https://github.com/ferama/jquery-expanding-textarea/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://fer-menta.blogspot.com/feeds/3599455736820322231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://fer-menta.blogspot.com/2010/12/jquery-expanding-textarea.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6696643292414056209/posts/default/3599455736820322231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6696643292414056209/posts/default/3599455736820322231'/><link rel='alternate' type='text/html' href='http://fer-menta.blogspot.com/2010/12/jquery-expanding-textarea.html' title='jQuery expanding textarea'/><author><name>marco</name><uri>http://www.blogger.com/profile/02488000778953844299</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSFC4OUYMFeczpiCLcbav4k_JMBbWYfEAyrva_Fy6DVuJ-oymHkkDujp6OR73WSwdHPI_JI_NjlH7CYnMb6tsP5LDkDd9mf6IREgJJ8L4jtIhzIlv0Y7z7ouPolRDZod4/s220/2.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6696643292414056209.post-2207774513208544826</id><published>2010-11-01T15:49:00.013+01:00</published><updated>2010-11-01T22:45:00.257+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Runtime dynamic models with django</title><content type='html'>I&#39;ve developed web apps for some years now using php, mostly old man style coding using raw PEAR. As soon as things growed up I discovered that the time to move was arrived. I&#39;ve done some research and come to django framework and I loved It :) I&#39;m still learning (I don&#39;t have any production app yet) but the alchemy is there so I think it will be my default choice soon.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;So what those dynamic models are?&lt;/span&gt;&lt;br /&gt;
In django you normally create models into models.py file for each app. So you must write the model class, but this isn&#39;t the only way to define a model in django. You can define models at runtime. You basically define a new python class at runtime using the python type module&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;Standard model definition:&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-python&quot;&gt;class Post(models.Model):
&amp;nbsp;&amp;nbsp; &amp;nbsp;title = models.CharField(max_length=255)
&amp;nbsp;&amp;nbsp; &amp;nbsp;content = models.TextField()
&lt;/pre&gt;&lt;i&gt;dynamic model definition&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-python&quot;&gt;import type

dct = {
&amp;nbsp;&amp;nbsp; &amp;nbsp;&quot;__module__&quot;: &quot;appname.models&quot;,
&amp;nbsp;&amp;nbsp; &amp;nbsp;&quot;title&quot;: models.CharField(max_length=255),
&amp;nbsp;&amp;nbsp; &amp;nbsp;&quot;content&quot;: models.TextField()
}
Post = type(&#39;Post&#39;, (models.Model,), dct)
&lt;/pre&gt;&lt;br /&gt;
What I&#39;m doing here is defining a new class named Post. I&#39;m comparing the two differnt ways to define the django model. In first case I have used the common way of defining a new django model. In the second I have used the python type module to define the model at runtime. The class inherit from models.Model class and have the attributes defined into dct. &amp;nbsp;This is tested to work with django 1.2.3. The dictnonary &lt;b&gt;dct,&lt;/b&gt;&amp;nbsp;contains all class attrs, so it can contain custom method also and even more. Note the &quot;__module__&quot; key: it is needed by the django admin interface to work and probably by something else so don&#39;t forget to put it. The value appname.models is refered to the model.py module where to put the runtime defined class. Note also that syncdb won&#39;t sync dynamic defined models so you must already have the model table on database.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-python&quot;&gt;def post_unicode(self):
&amp;nbsp;&amp;nbsp; &amp;nbsp;return self.name

dct[&#39;__unicode__&#39;] = post_unicode
&lt;/pre&gt;&lt;br /&gt;
We can even register the new defined type to the django admin interface&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-python&quot;&gt;admin.site.register(Post)
&lt;/pre&gt;&lt;br /&gt;
I&#39;ve discovered about dynamic models running on this page &lt;a href=&quot;http://code.djangoproject.com/wiki/DynamicModels&quot;&gt;http://code.djangoproject.com/wiki/DynamicModels&lt;/a&gt;. The writer complain about the fact that this technique is not applicable to django &amp;gt;= 1 but it worked very well in my experiments. Only note that I&#39;ve added __module__ key to the dict used to build the dynamic type</content><link rel='replies' type='application/atom+xml' href='http://fer-menta.blogspot.com/feeds/2207774513208544826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://fer-menta.blogspot.com/2010/11/runtime-dynamic-models-with-django.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6696643292414056209/posts/default/2207774513208544826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6696643292414056209/posts/default/2207774513208544826'/><link rel='alternate' type='text/html' href='http://fer-menta.blogspot.com/2010/11/runtime-dynamic-models-with-django.html' title='Runtime dynamic models with django'/><author><name>marco</name><uri>http://www.blogger.com/profile/02488000778953844299</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSFC4OUYMFeczpiCLcbav4k_JMBbWYfEAyrva_Fy6DVuJ-oymHkkDujp6OR73WSwdHPI_JI_NjlH7CYnMb6tsP5LDkDd9mf6IREgJJ8L4jtIhzIlv0Y7z7ouPolRDZod4/s220/2.jpg'/></author><thr:total>1</thr:total></entry></feed>