What's Cooking!? http://cooking.visualspace.nl/ What's Cooking!? http://cooking.visualspace.nl/ http://2.asset.soup.io/asset/0198/1522_49cd.png 44 44 Django projects cooking at Visualspace . [dokterbob] Finally: human friendly testing :) {"tags":[],"type":"link","title":"Finally: human friendly testing :)","source":"http://fakeapp.com/","body":null} <p><a href="http://fakeapp.com/">http://fakeapp.com/</a></p>Mon, 25 Oct 2010 22:39:42 GMThttp://cooking.visualspace.nl/post/84004557/Finally-human-friendly-testingurn:www-soup-io:1:84004557link [dokterbob] Ordering related objects in Django {"tags":[],"type":"link","title":"Ordering related objects in Django","source":"http://james.wheare.org/notes/2007/11/ordering-related-objects-in-django.php","body":null} <p><a href="http://james.wheare.org/notes/2007/11/ordering-related-objects-in-django.php">http://james.wheare.org/notes/2007/11/ordering-related-objects-in-django.php</a></p>Fri, 22 Oct 2010 11:21:50 GMThttp://cooking.visualspace.nl/post/83332796/Ordering-related-objects-in-Djangourn:www-soup-io:1:83332796link [dokterbob] django-multilingual-model {"tags":[],"type":"link","title":"django-multilingual-model","source":"http://code.google.com/p/django-multilingual-model/","body":"\u003Cp\u003EA very simple abstract base class, enabling translation of (specific) model fields with only about 33 lines of code.\u003C/p\u003E\n\u003Cp\u003E Example: \u003C/p\u003E\u003Cp\u003E\u003Ctt\u003Emodels.py\u003C/tt\u003E \u003C/p\u003E\u003Cpre\u003E\u00a0 \u00a0 from django.db import models\u003Cbr /\u003E\u00a0 \u00a0 from multiling import MultilingualModel\u003Cbr /\u003E\u00a0 \u00a0 \u003Cbr /\u003E\u00a0 \u00a0 class Language(models.Model):\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 code = models.CharField(max_length=5)\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 name = models.CharField(max_length=16)\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 \u003Cbr /\u003E\u00a0 \u00a0 class BookTranslation(models.Model):\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 language = models.ForeignKey(\"Language\")\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 title = models.CharField(max_length=32)\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 description = models.TextField()\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 model = models.ForeignKey(\"Book\")\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 \u003Cbr /\u003E\u00a0 \u00a0 class Book(MultilingualModel):\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 ISBN = models.IntegerField()\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 \u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 class Meta:\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 translation = BookTranslation\u003Cbr /\u003E\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 multilingual = ['title', 'description']\u003C/pre\u003E\u003Cpre class=\"prettyprint\"\u003E\u0026gt;\u0026gt;\u0026gt; lang_en = Language(code=\"en\", name=\"English\")\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; lang_en.save()\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; lang_pl = Language(code=\"pl\", name=\"Polish\")\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book = Book(ISBN=\"1234567890\")\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book.save()\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_en = BookTranslation()\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_en.title = \"Django for Dummies\"\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_en.description = \"Django described in simple words.\"\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_en.model = book\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_en.save()\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_pl = BookTranslation()\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_pl.title = \"Django dla Idiotow\"\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_pl.description = \"Django opisane w prostych slowach\"\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_pl.model = book\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book_pl.save()\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; \u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; # now here comes the magic\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book.title_en\u003Cbr /\u003Eu'Django for Dummies'\u003Cbr /\u003E\u0026gt;\u0026gt;\u0026gt; book.description_pl\u003Cbr /\u003Eu'Django opisane w prostych slowach'\u003C/pre\u003E\u003Cp\u003ETo have it interated with Django Admin nicely, try this: \u003C/p\u003E\u003Cp\u003E\u003Ctt\u003Eadmin.py\u003C/tt\u003E \u003C/p\u003E\u003Cpre class=\"prettyprint\"\u003Efrom django.contrib import admin\u003Cbr /\u003Eimport models\u003Cbr /\u003E\u003Cbr /\u003Eclass BookTranslationInline(admin.StackedInline):\u003Cbr /\u003E\u00a0 \u00a0model = models.BookTranslation\u003Cbr /\u003E\u00a0 \u00a0extra = 1\u003Cbr /\u003E\u00a0 \u00a0min_num = 1\u003Cbr /\u003E\u003Cbr /\u003E\u003Cbr /\u003Eclass BookAdmin(admin.ModelAdmin):\u003Cbr /\u003E\u00a0 \u00a0list_display = [\"ISBN\"]\u003Cbr /\u003E\u00a0 \u00a0inlines = [BookTranslationInline]\u003Cbr /\u003E\u003Cbr /\u003Eadmin.site.register(models.Book, BookAdmin)\u003C/pre\u003E\n"} <p><p>A very simple abstract base class, enabling translation of (specific) model fields with only about 33 lines of code.</p> <p> Example: </p><p><tt>models.py</tt> </p><pre>    from django.db import models<br />    from multiling import MultilingualModel<br />    <br />    class Language(models.Model):<br />        code = models.CharField(max_length=5)<br />        name = models.CharField(max_length=16)<br />        <br />    class BookTranslation(models.Model):<br />        language = models.ForeignKey("Language")<br />        title = models.CharField(max_length=32)<br />        description = models.TextField()<br />        model = models.ForeignKey("Book")<br />        <br />    class Book(MultilingualModel):<br />        ISBN = models.IntegerField()<br />        <br />        class Meta:<br />            translation = BookTranslation<br />            multilingual = ['title', 'description']</pre><pre class="prettyprint">&gt;&gt;&gt; lang_en = Language(code="en", name="English")<br />&gt;&gt;&gt; lang_en.save()<br />&gt;&gt;&gt; lang_pl = Language(code="pl", name="Polish")<br />&gt;&gt;&gt; book = Book(ISBN="1234567890")<br />&gt;&gt;&gt; book.save()<br />&gt;&gt;&gt; book_en = BookTranslation()<br />&gt;&gt;&gt; book_en.title = "Django for Dummies"<br />&gt;&gt;&gt; book_en.description = "Django described in simple words."<br />&gt;&gt;&gt; book_en.model = book<br />&gt;&gt;&gt; book_en.save()<br />&gt;&gt;&gt; book_pl = BookTranslation()<br />&gt;&gt;&gt; book_pl.title = "Django dla Idiotow"<br />&gt;&gt;&gt; book_pl.description = "Django opisane w prostych slowach"<br />&gt;&gt;&gt; book_pl.model = book<br />&gt;&gt;&gt; book_pl.save()<br />&gt;&gt;&gt; <br />&gt;&gt;&gt; # now here comes the magic<br />&gt;&gt;&gt; book.title_en<br />u'Django for Dummies'<br />&gt;&gt;&gt; book.description_pl<br />u'Django opisane w prostych slowach'</pre><p>To have it interated with Django Admin nicely, try this: </p><p><tt>admin.py</tt> </p><pre class="prettyprint">from django.contrib import admin<br />import models<br /><br />class BookTranslationInline(admin.StackedInline):<br />   model = models.BookTranslation<br />   extra = 1<br />   min_num = 1<br /><br /><br />class BookAdmin(admin.ModelAdmin):<br />   list_display = ["ISBN"]<br />   inlines = [BookTranslationInline]<br /><br />admin.site.register(models.Book, BookAdmin)</pre> </p> <p><a href="http://code.google.com/p/django-multilingual-model/">http://code.google.com/p/django-multilingual-model/</a></p>Fri, 22 Oct 2010 11:06:11 GMThttp://cooking.visualspace.nl/post/83330597/django-multilingual-modelurn:www-soup-io:1:83330597link [dokterbob] django-mobile {"tags":[],"type":"link","title":"django-mobile","source":"http://pypi.python.org/pypi/django-mobile/0.1.1","body":"\u003Cp\u003E\u003Cstrong\u003Edjango-mobile\u003C/strong\u003E\u00a0provides a simple way to detect mobile browsers and gives you tools at your hand to render some different templates to deliver a mobile version of your site to the user.\u003C/p\u003E\u003Cdiv\u003E\u003Cbr /\u003E\u003C/div\u003E"} <p><p><strong>django-mobile</strong> provides a simple way to detect mobile browsers and gives you tools at your hand to render some different templates to deliver a mobile version of your site to the user.</p><div><br /></div></p> <p><a href="http://pypi.python.org/pypi/django-mobile/0.1.1">http://pypi.python.org/pypi/django-mobile/0.1.1</a></p>Mon, 18 Oct 2010 23:51:32 GMThttp://cooking.visualspace.nl/post/82654624/django-mobileurn:www-soup-io:1:82654624link [dokterbob] Hg-Git Mercurial Plugin {"tags":[],"type":"link","title":"Hg-Git Mercurial Plugin","source":"http://hg-git.github.com/","body":"\u003Cp\u003EThis is the Hg-Git plugin for Mercurial, adding the ability to\u00a0\u003Cstrong\u003Epush to and pull from a Git server\u003C/strong\u003E\u00a0repository from Mercurial. This means you can collaborate on Git based projects from Mercurial, or use a Git server as a collaboration point for a team with developers using both Git and Mercurial.\u003C/p\u003E\n\u003Cp\u003E\u003Cimg src=\"http://hg-git.github.com/images/server.png\" /\u003E\u003C/p\u003E"} <p><p>This is the Hg-Git plugin for Mercurial, adding the ability to <strong>push to and pull from a Git server</strong> repository from Mercurial. This means you can collaborate on Git based projects from Mercurial, or use a Git server as a collaboration point for a team with developers using both Git and Mercurial.</p> <p><img src="http://hg-git.github.com/images/server.png" /></p></p> <p><a href="http://hg-git.github.com/">http://hg-git.github.com/</a></p>Mon, 18 Oct 2010 09:54:26 GMThttp://cooking.visualspace.nl/post/82528747/Hg-Git-Mercurial-Pluginurn:www-soup-io:1:82528747link [visualspace] X-Sendfile static file serve view {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/2226/\"\u003EX-Sendfile static file serve view\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/2226/","body":"\u003Cp\u003EThis view has the same functionality as Django's builtin static view function but when the configuration option \u003Ccode\u003EUSE_XSENDFILE = True\u003C/code\u003E is specified in the settings it returns the absolute path of the file instead of its contents. \n\u003C/p\u003E\n\u003Cp\u003EThis allows the mod_xsendfile module in Apache or Lighttpd to take care of ...\u003C/p\u003E"} <p>This view has the same functionality as Django's builtin static view function but when the configuration option <code>USE_XSENDFILE = True</code> is specified in the settings it returns the absolute path of the file instead of its contents. </p> <p>This allows the mod_xsendfile module in Apache or Lighttpd to take care of ...</p>Thu, 07 Oct 2010 13:33:20 GMThttp://cooking.visualspace.nl/post/80836969/X-Sendfile-static-file-serve-viewurn:www-soup-io:1:80836969regular [dokterbob] django-fileprocessor: efficient, scalable processing of files (ie. scaling images) {"tags":["django","image","scaling","efficiency","api","files","processing"],"type":"link","title":"django-fileprocessor: efficient, scalable processing of files (ie. scaling images)","source":"http://github.com/dokterbob/django-fileprocessor","body":"\u003Cp\u003E\u003Cstrong\u003EThis is a prototype project for something we have been wanting to make: efficient file processing - from within templates!\u003C/strong\u003E\u003C/p\u003E\n\n\u003Cp\u003ERight now, if you are like me, you probably use something like easy_thumbnail for scaling of images for your website. You might even have written some code to extract thumbnails from PDF files or from video files. All really great work!\u003C/p\u003E\n\n\u003Cp\u003EBUT. As our applications relying on this stuff might actually scale up a bit, the amount of work our application servers are doing WHILE RENDERING THE TEMPLATE can quickly become excessive. At the same time, if these servers were just doing what they should be, namely data \u0026lt;-\u0026gt; view interactions, this would not be happening.\u003C/p\u003E\n\n\u003Cp\u003EMoreover: if your server is, in principle, able to handle a mentioning on some lame but immensely popular blog - why should it not be in practice? Because, right now - if you use \u003Ca href=\"http://github.com/SmileyChris/easy-thumbnails/tree/master/easy_thumbnails\"\u003Eeasy_thumbnails\u003C/a\u003E - your server will block while rendering templates until your thumbnails are gone.\u003C/p\u003E\n\n\u003Cp\u003ESo here is my concept solution: When we need to do something with a file, while rendering a template, we first put out a request. This request can be put out to some other server, but for small instances it can easily be the same server - just some other CPU doing the work. This 'remote tag' basically passes any contents between the \u003Ccode\u003E{% fileprocessor %}\u003C/code\u003E and \u003Ccode\u003E{% endfileprocessor %}\u003C/code\u003E along to this other server as a parameter (so far called instructions), telling it what to do and where to get stuff from.\u003C/p\u003E\n\n\u003Cp\u003EThe remote server writes this to the database, generates a checksum thereof and parses the instructions just well enough to generate some kind of representation (ie. and image tag) of the stuff that will be rendered \u003Cem\u003Elater\u003C/em\u003E.\u003C/p\u003E\n\n\u003Cp\u003EAfter the HTML has been sent out to the client, the client will start making individual requests for the URL's referred to in the representation code generate while rendering the template. Calling these URL's directly triggers processing the file in any possible way, according to the instructions in the database. When this is done, the file is written to some kind of storage, somewhere and a redirect to this file is generated.\u003C/p\u003E\n\n\u003Cp\u003EOn subsequent requests, all the 'file processing server' does is blurt out redirects to that some old file. But as these are permanent redirects, they should also be cached by the client which ought to be quite efficient. Furthermore, the template rendering results can and should also be cached: we do not have to reach out to the server all of the time to retreive the same kind of data.\u003C/p\u003E\n\n\u003Cp\u003ESo that's it. A work in progress. Feel free to join in. :)\u003C/p\u003E"} <p><p><strong>This is a prototype project for something we have been wanting to make: efficient file processing - from within templates!</strong></p> <p>Right now, if you are like me, you probably use something like easy_thumbnail for scaling of images for your website. You might even have written some code to extract thumbnails from PDF files or from video files. All really great work!</p> <p>BUT. As our applications relying on this stuff might actually scale up a bit, the amount of work our application servers are doing WHILE RENDERING THE TEMPLATE can quickly become excessive. At the same time, if these servers were just doing what they should be, namely data &lt;-&gt; view interactions, this would not be happening.</p> <p>Moreover: if your server is, in principle, able to handle a mentioning on some lame but immensely popular blog - why should it not be in practice? Because, right now - if you use <a href="http://github.com/SmileyChris/easy-thumbnails/tree/master/easy_thumbnails">easy_thumbnails</a> - your server will block while rendering templates until your thumbnails are gone.</p> <p>So here is my concept solution: When we need to do something with a file, while rendering a template, we first put out a request. This request can be put out to some other server, but for small instances it can easily be the same server - just some other CPU doing the work. This 'remote tag' basically passes any contents between the <code>{% fileprocessor %}</code> and <code>{% endfileprocessor %}</code> along to this other server as a parameter (so far called instructions), telling it what to do and where to get stuff from.</p> <p>The remote server writes this to the database, generates a checksum thereof and parses the instructions just well enough to generate some kind of representation (ie. and image tag) of the stuff that will be rendered <em>later</em>.</p> <p>After the HTML has been sent out to the client, the client will start making individual requests for the URL's referred to in the representation code generate while rendering the template. Calling these URL's directly triggers processing the file in any possible way, according to the instructions in the database. When this is done, the file is written to some kind of storage, somewhere and a redirect to this file is generated.</p> <p>On subsequent requests, all the 'file processing server' does is blurt out redirects to that some old file. But as these are permanent redirects, they should also be cached by the client which ought to be quite efficient. Furthermore, the template rendering results can and should also be cached: we do not have to reach out to the server all of the time to retreive the same kind of data.</p> <p>So that's it. A work in progress. Feel free to join in. :)</p></p> <p><a href="http://github.com/dokterbob/django-fileprocessor">http://github.com/dokterbob/django-fileprocessor</a></p>Thu, 30 Sep 2010 14:02:20 GMThttp://cooking.visualspace.nl/post/79515630/django-fileprocessor-efficient-scalable-processing-of-filesurn:www-soup-io:1:79515630linkdjangoimagescalingefficiencyapifilesprocessing [dokterbob] django-newsletter released in the Cheese Shop {"tags":[],"type":"link","title":"django-newsletter released in the Cheese Shop","source":"http://pypi.python.org/pypi/django-newsletter","body":"\u003Cp\u003EAfter a long time of though work we have finally released this app for managing multiple mass-mailing lists with both plaintext as well as HTML templates (and TinyMCE editor for HTML messages), images and a smart queueing system all right from the admin interface. And what's more: it's all fully integrated into the Django admin.\u003C/p\u003E\n\u003Cp\u003EStay tuned for some screenshots - or perhaps even a screencast of our (Dutch) presentation of the project this wednesday at the \u003Ca href=\"http://wiki.python.org/moin/DjangoMeetingNL/DM/ABC290910\"\u003EDjango Meeting in Amsterdam\u003C/a\u003E.\u003C/p\u003E"} <p><p>After a long time of though work we have finally released this app for managing multiple mass-mailing lists with both plaintext as well as HTML templates (and TinyMCE editor for HTML messages), images and a smart queueing system all right from the admin interface. And what's more: it's all fully integrated into the Django admin.</p> <p>Stay tuned for some screenshots - or perhaps even a screencast of our (Dutch) presentation of the project this wednesday at the <a href="http://wiki.python.org/moin/DjangoMeetingNL/DM/ABC290910">Django Meeting in Amsterdam</a>.</p></p> <p><a href="http://pypi.python.org/pypi/django-newsletter">http://pypi.python.org/pypi/django-newsletter</a></p>Sun, 26 Sep 2010 15:11:10 GMThttp://cooking.visualspace.nl/post/78783739/django-newsletter-released-in-the-Cheese-Shopurn:www-soup-io:1:78783739link [visualspace] Improved many-page pagination {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/2199/\"\u003EImproved many-page pagination\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/2199/","body":"\u003Cp\u003EThis one was adapted from \u003Ca href=\"http://djangosnippets.org/snippets/1441/\"\u003EPage numbers with ... like in Digg\u003C/a\u003E. See that one for more reference.\n\u003C/p\u003E\n\u003Cp\u003EDigg-like page numbering using inclusion tag.\n\u003C/p\u003E\n\u003Cp\u003EUsage in template:\n\u003C/p\u003E\n\u003Cp\u003E\u003Ccode\u003E{% load pagination %}\n{% pagination yourpage %}\u003C/code\u003E\n\u003C/p\u003E\n\u003Cp\u003EInclusion template pagination.html:\n\u003C/p\u003E\n\u003Cpre\u003E\u003Ccode\u003E{% if page.has_previous %}\n \u0026lt;a href=\"?page={{ page.previous_page_number }}\"\u0026gt;\u0026lt;img src=\"{{ MEDIA_URL }}images/page/cyclenav_l.png\" alt ...\u003C/code\u003E\u003C/pre\u003E"} <p>This one was adapted from <a href="http://djangosnippets.org/snippets/1441/">Page numbers with ... like in Digg</a>. See that one for more reference. </p> <p>Digg-like page numbering using inclusion tag. </p> <p>Usage in template: </p> <p><code>{% load pagination %} {% pagination yourpage %}</code> </p> <p>Inclusion template pagination.html: </p> <pre><code>{% if page.has_previous %} &lt;a href="?page={{ page.previous_page_number }}"&gt;&lt;img src="{{ MEDIA_URL }}images/page/cyclenav_l.png" alt ...</code></pre>Thu, 16 Sep 2010 19:59:38 GMThttp://cooking.visualspace.nl/post/77026089/Improved-many-page-paginationurn:www-soup-io:1:77026089regular [dokterbob] (Image) {"tags":[],"type":"image","source":null,"body":null,"url":"http://2.asset.soup.io/asset/0919/8930_e44e.png"} <p><a href=""><img alt="8930_e44e_400" height="300" src="http://2.asset.soup.io/asset/0919/8930_e44e_400.png" width="400" /></a></p> <p></p>Sun, 11 Jul 2010 18:39:30 GMThttp://cooking.visualspace.nl/post/64808615/Imageurn:www-soup-io:1:64808615image [dokterbob] LESS {"tags":[],"type":"link","title":"LESS","source":"http://lesscss.org/","body":"Less extends CSS with: variables, mixins, operations and nested rules."} <p>Less extends CSS with: variables, mixins, operations and nested rules.</p> <p><a href="http://lesscss.org/">http://lesscss.org/</a></p>Tue, 06 Jul 2010 19:30:02 GMThttp://cooking.visualspace.nl/post/63948223/LESSurn:www-soup-io:1:63948223link [dokterbob] (Video) {"tags":[],"type":"video","source":"http://www.youtube.com/watch?v=vYMpihXHobQ","body":null,"embedcode_or_url":"http://www.youtube.com/watch?v=vYMpihXHobQ"} <object height="350" width="425"><param name="movie" value="http://www.youtube.com/v/vYMpihXHobQ" /><param name="wmode" value="transparent" /><embed src="http://www.youtube.com/v/vYMpihXHobQ" wmode="transparent" type="application/x-shockwave-flash" height="350" width="425" /></object>Sat, 29 May 2010 13:17:33 GMThttp://cooking.visualspace.nl/post/58026459/Videourn:www-soup-io:1:58026459video [dokterbob] Introduction to Surlex {"tags":[],"type":"link","title":"Introduction to Surlex","source":"http://codysoyland.com/2009/sep/6/introduction-surlex/","body":"Surlex (Simple URL Expression) is a language for matching and extracting text, similar to regex (regular expression). It works by generating a regular expression from a more concise syntax that is designed to produce easy-to-read url patterns."} <p>Surlex (Simple URL Expression) is a language for matching and extracting text, similar to regex (regular expression). It works by generating a regular expression from a more concise syntax that is designed to produce easy-to-read url patterns.</p> <p><a href="http://codysoyland.com/2009/sep/6/introduction-surlex/">http://codysoyland.com/2009/sep/6/introduction-surlex/</a></p>Tue, 13 Apr 2010 09:52:43 GMThttp://cooking.visualspace.nl/post/52904706/Introduction-to-Surlexurn:www-soup-io:1:52904706link [dokterbob] django-google-analytics - Project Hosting on Google Code {"tags":[],"type":"link","title":"django-google-analytics - Project Hosting on Google Code","source":"http://code.google.com/p/django-google-analytics/","body":"A simple django application that eases Google Analytics integration with your Django projects"} <p>A simple django application that eases Google Analytics integration with your Django projects</p> <p><a href="http://code.google.com/p/django-google-analytics/">http://code.google.com/p/django-google-analytics/</a></p><p>[Reposted from <span class="user_container user174729" ><a class="" href="http://djangofeeds.soup.io/post/43268631/django-google-analytics-Project-Hosting-on-Google"><span class="name">djangofeeds</span></a></span>]</p>Tue, 02 Feb 2010 22:10:19 GMThttp://cooking.visualspace.nl/post/44142451/django-google-analytics-Project-Hosting-on-Googleurn:www-soup-io:1:44142451link [visualspace] ExtendibleAdmin class {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/1804/\"\u003EExtendibleAdmin class\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/1804/","body":"\u003Cp\u003EA generic base class for extending ModelAdmin views. This can be used likewise:\n\u003C/p\u003E\n\u003Cpre\u003E\u003Ccode\u003Edef myview(self, request, object_id):\n obj = self._getobj(request, object_id)\n \u0026lt; do something \u0026gt;\n\ndef get_urls(self):\n urls = super(MyAdmin, self).get_urls()\n\n my_urls = patterns('',\n url(r'^(.+)/myview/$', \n self._wrap(self.myview), \n name=self._view_name('myview')),\n )\n\n return my_urls + urls\n\u003C/code\u003E\u003C/pre\u003E"} <p>A generic base class for extending ModelAdmin views. This can be used likewise: </p> <pre><code>def myview(self, request, object_id): obj = self._getobj(request, object_id) &lt; do something &gt; def get_urls(self): urls = super(MyAdmin, self).get_urls() my_urls = patterns('', url(r'^(.+)/myview/$', self._wrap(self.myview), name=self._view_name('myview')), ) return my_urls + urls </code></pre>Tue, 17 Nov 2009 06:46:47 GMThttp://cooking.visualspace.nl/post/34837541/ExtendibleAdmin-classurn:www-soup-io:1:34837541regular [visualspace] Remove named field from fieldsets {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/1803/\"\u003ERemove named field from fieldsets\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/1803/","body":"\u003Cp\u003EThis snipped removes a specific field from the fieldsets. This is very useful to leave a field 'out' in the admin, likewise:\n\u003C/p\u003E\n\u003Cpre\u003E\u003Ccode\u003Edef get_fieldsets(self, request, obj=None):\n fieldsets = super(BlaModelAdmin, self).get_fieldsets(request, obj)\n\n if not request.user.has_perm('change_blah'):\n remove_from_fieldsets(fieldsets, 'blah')\n\u003C/code\u003E\u003C/pre\u003E"} <p>This snipped removes a specific field from the fieldsets. This is very useful to leave a field 'out' in the admin, likewise: </p> <pre><code>def get_fieldsets(self, request, obj=None): fieldsets = super(BlaModelAdmin, self).get_fieldsets(request, obj) if not request.user.has_perm('change_blah'): remove_from_fieldsets(fieldsets, 'blah') </code></pre>Tue, 17 Nov 2009 06:11:54 GMThttp://cooking.visualspace.nl/post/34837542/Remove-named-field-from-fieldsetsurn:www-soup-io:1:34837542regular [dokterbob] Git Repository Basics Guide {"tags":[],"type":"link","title":"Git Repository Basics Guide","source":"http://wiki.sourcemage.org/Git_Guide","body":null} <p><a href="http://wiki.sourcemage.org/Git_Guide">http://wiki.sourcemage.org/Git_Guide</a></p>Fri, 24 Jul 2009 14:23:50 GMThttp://cooking.visualspace.nl/post/23864729/Git-Repository-Basics-Guideurn:www-soup-io:1:23864729link [dokterbob] Setting up a new remote git repository {"tags":[],"type":"link","title":"Setting up a new remote git repository","source":"http://toolmantim.com/articles/setting_up_a_new_remote_git_repository","body":"To collaborate in a distributed development process you\u2019ll need to push code to remotely accessible repositories."} <p>To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.</p> <p><a href="http://toolmantim.com/articles/setting_up_a_new_remote_git_repository">http://toolmantim.com/articles/setting_up_a_new_remote_git_repository</a></p>Fri, 24 Jul 2009 13:50:32 GMThttp://cooking.visualspace.nl/post/23862874/Setting-up-a-new-remote-git-repositoryurn:www-soup-io:1:23862874link [visualspace] Python Calendar wrapper template tag {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/1485/\"\u003EPython Calendar wrapper template tag\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/1485/","body":"\u003Cp\u003EThis tag gives you an iterable Python \u003Ca href=\"http://docs.python.org/library/calendar.html\"\u003ECalendar object\u003C/a\u003E in your template namespace. It is used in the \u003Ca href=\"http://github.com/dokterbob/django-agenda\"\u003Edjango-calendar\u003C/a\u003E project.\n\u003C/p\u003E\n\u003Cp\u003EUse it as follows in your template:\n\u003C/p\u003E\n\u003Cpre\u003E\u003Ccode\u003E{% get_calendar for \u0026lt;month_number_or_variable\u0026gt; \u0026lt;year_or_variable\u0026gt; as calendar %}\n\u0026lt;table\u0026gt;\n \u0026lt;tr\u0026gt;\n \u0026lt;th\u0026gt;Mon\u0026lt;/th\u0026gt;\n \u0026lt;th\u0026gt;Tue\u0026lt;/th\u0026gt;\n \u0026lt;th\u0026gt;Wed\u0026lt;/th\u0026gt;\n \u0026lt;th\u0026gt;Thu\u0026lt;/th\u0026gt;\n \u0026lt;th\u0026gt;Fri\u0026lt;/th ...\u003C/code\u003E\u003C/pre\u003E"} <p>This tag gives you an iterable Python <a href="http://docs.python.org/library/calendar.html">Calendar object</a> in your template namespace. It is used in the <a href="http://github.com/dokterbob/django-agenda">django-calendar</a> project. </p> <p>Use it as follows in your template: </p> <pre><code>{% get_calendar for &lt;month_number_or_variable&gt; &lt;year_or_variable&gt; as calendar %} &lt;table&gt; &lt;tr&gt; &lt;th&gt;Mon&lt;/th&gt; &lt;th&gt;Tue&lt;/th&gt; &lt;th&gt;Wed&lt;/th&gt; &lt;th&gt;Thu&lt;/th&gt; &lt;th&gt;Fri&lt;/th ...</code></pre>Tue, 05 May 2009 08:20:03 GMThttp://cooking.visualspace.nl/post/18536767/Python-Calendar-wrapper-template-tagurn:www-soup-io:1:18536767regular [visualspace] Soft hyphenation (­) template filter using PyHyphen {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/1446/\"\u003ESoft hyphenation (\u00ad) template filter using PyHyphen\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/1446/","body":"\u003Cp\u003EThis template filter is meant to insert soft hyphens (\u003Ca href=\"http://www.cs.tut.fi/~jkorpela/shy.html\"\u003E\u0026amp;shy; entities\u003C/a\u003E) in text whever it can. For this is relies on a \u003Cstrong\u003Erecent\u003C/strong\u003E checkout of the \u003Ca href=\"http://code.google.com/p/pyhyphen/\"\u003EPyHyphen\u003C/a\u003E interface to the hyphen-2.3 C library, which is also used by Mozilla and OpenOffice.org.\n\u003C/p\u003E\n\u003Cp\u003EIt takes two optional parameters: the language ...\u003C/p\u003E"} <p>This template filter is meant to insert soft hyphens (<a href="http://www.cs.tut.fi/~jkorpela/shy.html">&amp;shy; entities</a>) in text whever it can. For this is relies on a <strong>recent</strong> checkout of the <a href="http://code.google.com/p/pyhyphen/">PyHyphen</a> interface to the hyphen-2.3 C library, which is also used by Mozilla and OpenOffice.org. </p> <p>It takes two optional parameters: the language ...</p>Thu, 16 Apr 2009 19:10:01 GMThttp://cooking.visualspace.nl/post/17398500/Soft-hyphenation-template-filter-using-PyHyphenurn:www-soup-io:1:17398500regular [dokterbob] Django Guestbook application {"tags":[],"type":"regular","title":"Django Guestbook application","source":null,"body":"\u003Cp\u003EThe other day I've written a pluggable guestbook application for Django. It is fully functioning and loosely based on the Django comments contrib. Currently, I am using it on a small website (\u003Ca href=\"http://www.hansenpaul120.nl/guestbook/\"\u003Ehansenpaul120.nl\u003C/a\u003E, Dutch) but more websites are soon to follow.\u003C/p\u003E\n\n\u003Cp\u003ECurrent features:\n\u003C/p\u003E\u003Cul\u003E\n \u003Cli\u003EFully translatable (currently, only English and Dutch are available)\u003C/li\u003E\n \u003Cli\u003EFully integrated with the admin\u003C/li\u003E\n \u003Cli\u003ESome barebone templates are supplied\u003C/li\u003E\n\u003C/ul\u003E\n\u003Cp\u003EMore features will be added as soon as I am going to use this in more sites, or when \u003Cb\u003Eyou\u003C/b\u003E do so. Some of these features may include:\n\u003C/p\u003E\u003Cul\u003E\n \u003Cli\u003E(Better) documentation.\u003C/li\u003E\n \u003Cli\u003EIntegration with \u003Ca href=\"http://docs.djangoproject.com/en/dev/ref/contrib/syndication/\"\u003EDjango syndication\u003C/a\u003E\u003C/li\u003E\n \u003Cli\u003EIntegration with \u003Ca href=\"http://code.google.com/p/django-email-confirmation/\"\u003EDjango email confirmation\u003C/a\u003E\u003C/li\u003E\n \u003Cli\u003EIntegration with \u003Ca href=\"http://docs.djangoproject.com/en/dev/topics/auth/\"\u003EDjango User authentication\u003C/a\u003E\u003C/li\u003E\n\u003C/ul\u003E\n\n\u003Cp\u003EInstallation should be pretty straight-forward for anyone who's installed a Django app before:\n\u003C/p\u003E\u003Col\u003E\n \u003Cli\u003EGet the source from \u003Ca href=\"http://github.com/dokterbob/django-guestbook/\"\u003EGitHub\u003C/a\u003E by either cloning or downloading the archive.\u003C/li\u003E\n \u003Cli\u003ELink the guestbook app into your project's tree:\u003Cbr /\u003E\n \u003Cpre\u003Eln -s django-guestbook/guestbook guestbook\u003C/pre\u003E\n \u003C/li\u003E\n \u003Cli\u003EAdd the app to your \u003Ccode\u003EINSTALLED_APPS\u003C/code\u003E in \u003Ccode\u003Esettings.py\u003C/code\u003E:\u003Cbr /\u003E\n \u003Cpre\u003EINSTALLED_APPS = (\u003Cbr /\u003E ...\u003Cbr /\u003E 'django.contrib.admin',\u003Cbr /\u003E 'guestbook',\u003Cbr /\u003E)\u003C/pre\u003E\n \u003C/li\u003E\u003Cli\u003EAdd the guestbook app to your \u003Ccode\u003Eurls.py\u003C/code\u003E:\u003Cbr /\u003E\n \u003Cpre\u003Eurlpatterns = patterns('',\u003Cbr /\u003E ...\u003Cbr /\u003E (r'^guestbook/', include('guestbook.urls')), \u003Cbr /\u003E)\u003C/pre\u003E\n \u003C/li\u003E\u003Cli\u003EUpdate the database structure:\u003Cbr /\u003E\n \u003Cpre\u003E./manage.py syncdb\u003C/pre\u003E\n \u003C/li\u003E\n \u003Cli\u003EYou're done! Go and test your app by running:\u003Cbr /\u003E\n \u003Cpre\u003E./manage.py runserver\u003C/pre\u003E\n \u003C/li\u003E\n\u003C/ol\u003E\n\u003Cp\u003EFeel free to provide feedback on the current state of the project, and perhaps on what features you might like. In any case, expect a more complete HOWTO here.\u003C/p\u003E\n\n\u003Cp\u003EThe app's source code can be found \u003Ca href=\"http://github.com/dokterbob/django-guestbook/\"\u003Ehere\u003C/a\u003E on GitHub and the source for the hansenpaul120.nl website is \u003Ca href=\"http://github.com/dokterbob/hansenpaul/\"\u003Ehere\u003C/a\u003E. The latter might be a good place to see how the guestbook application can be used.\u003C/p\u003E"} <p>The other day I've written a pluggable guestbook application for Django. It is fully functioning and loosely based on the Django comments contrib. Currently, I am using it on a small website (<a href="http://www.hansenpaul120.nl/guestbook/">hansenpaul120.nl</a>, Dutch) but more websites are soon to follow.</p> <p>Current features: </p><ul> <li>Fully translatable (currently, only English and Dutch are available)</li> <li>Fully integrated with the admin</li> <li>Some barebone templates are supplied</li> </ul> <p>More features will be added as soon as I am going to use this in more sites, or when <b>you</b> do so. Some of these features may include: </p><ul> <li>(Better) documentation.</li> <li>Integration with <a href="http://docs.djangoproject.com/en/dev/ref/contrib/syndication/">Django syndication</a></li> <li>Integration with <a href="http://code.google.com/p/django-email-confirmation/">Django email confirmation</a></li> <li>Integration with <a href="http://docs.djangoproject.com/en/dev/topics/auth/">Django User authentication</a></li> </ul> <p>Installation should be pretty straight-forward for anyone who's installed a Django app before: </p><ol> <li>Get the source from <a href="http://github.com/dokterbob/django-guestbook/">GitHub</a> by either cloning or downloading the archive.</li> <li>Link the guestbook app into your project's tree:<br /> <pre>ln -s django-guestbook/guestbook guestbook</pre> </li> <li>Add the app to your <code>INSTALLED_APPS</code> in <code>settings.py</code>:<br /> <pre>INSTALLED_APPS = (<br /> ...<br /> 'django.contrib.admin',<br /> 'guestbook',<br />)</pre> </li><li>Add the guestbook app to your <code>urls.py</code>:<br /> <pre>urlpatterns = patterns('',<br /> ...<br /> (r'^guestbook/', include('guestbook.urls')), <br />)</pre> </li><li>Update the database structure:<br /> <pre>./manage.py syncdb</pre> </li> <li>You're done! Go and test your app by running:<br /> <pre>./manage.py runserver</pre> </li> </ol> <p>Feel free to provide feedback on the current state of the project, and perhaps on what features you might like. In any case, expect a more complete HOWTO here.</p> <p>The app's source code can be found <a href="http://github.com/dokterbob/django-guestbook/">here</a> on GitHub and the source for the hansenpaul120.nl website is <a href="http://github.com/dokterbob/hansenpaul/">here</a>. The latter might be a good place to see how the guestbook application can be used.</p>Tue, 23 Dec 2008 12:07:38 GMThttp://cooking.visualspace.nl/post/9992059/Django-Guestbook-applicationurn:www-soup-io:1:9992059regular [visualspace] Default to current/all sites in admin {"tags":[],"type":"regular","title":"\u003Ca href=\"http://www.djangosnippets.org/snippets/1128/\"\u003EDefault to current/all sites in admin\u003C/a\u003E","source":"http://www.djangosnippets.org/snippets/1128/","body":"\u003Cp\u003EThis code sets the default sites for a sites ManyToMany property of a model to \u003Ccode\u003ESite.objects.all()\u003C/code\u003E.\n This could easily be changed to \u003Ccode\u003ESite.objects.get_current()\u003C/code\u003E to use the current site as default.\n\u003C/p\u003E\n\u003Cp\u003ESurely, we should be able to use \u003Ccode\u003Edefault=[Site.objects.get_current()\u003C/code\u003E in the model \u003Cem\u003Ebut\u003C/em\u003E apparently ...\u003C/p\u003E"} <p>This code sets the default sites for a sites ManyToMany property of a model to <code>Site.objects.all()</code>. This could easily be changed to <code>Site.objects.get_current()</code> to use the current site as default. </p> <p>Surely, we should be able to use <code>default=[Site.objects.get_current()</code> in the model <em>but</em> apparently ...</p>Sun, 12 Oct 2008 04:43:14 GMThttp://cooking.visualspace.nl/post/17390149/Default-to-current-all-sites-in-adminurn:www-soup-io:1:17390149regular