A CompressedTextField to transparently save data gzipped in the database and uncompress at retrieval. Full description at my blog: [arnebrodowski.de/...Field-for-Django.html](http://www.arnebrodowski.de/blog/435-Implementing-a-CompressedTextField-for-Django.html)
Usage:
{% ifmodulo forloop.counter 4 0 %}
<!-- do something -->
{% else %}
<!-- do something else -->
{% endifmodulo %}
or
{% ifnotmodulo 5 3 %}
<!-- do something -->
{% else %}
<!-- do something else -->
{% endifmodulo %}
When the third parameter does not exist, it is assumed you're checking for values different than 0.
Ttemplates and filters for quoting e-mails in templates.
The `quoted_email` tag takes a template, renders it and quotes the result.
The `quote_text` filter puts one or more levels of quotes around the passed text.
This was a much better way of incrementing variables that only changed a small amount in name. deltab in #python also said I could have used tuples, but I'm not familiar with them yet, so I added this to a list of things to look into.
**Usage** (*in template*):
<img src="{{ MEDIA_URL }}2007/images/{% filter split:","|random %}theimage1.jpg,something2.jpg,thirdisthecharm.jpg{% endfilter %}" />
I decided to make it simple, because one template creator wanted to add random images to different places of templates. Creating something huge, like external image filename parsing was not necessary in this case.
month_ids is a list of months like this...
[('Apr07', 'April 2007'), ('Mar07', 'March 2007'), ('Feb07', 'February 2007')]
which can be used in a select box like this..
month = forms.ChoiceField(choices=(months))
If you work with Django like I do, you have a separate installation or Subversion check-out of Django for each of your projects. Currently each one of them eats 22 MB of disk space.
This utility hard-links all identical files between copies of Django. They can even be different versions or svn revisions, and you'll still be able to free a good amount of disk space.
Run this every now and then if you update installed copies of Django or add new ones.
This utility is available also [here](http://trac.ambitone.com/ambidjangolib/browser/trunk/hardlink_django_instances/hardlink_django_instances.py).
Does a digg url effect to a string, can be useful for using an item's title in the url,
from this:
.hi's., is (a) $ [test], will it "work"/ \
to this:
his_is_a_test_will_it_work
I understand this isn't a very well made script, I am not very good at string manipulation. But I would be happy if someone would recode it in a faster, more managable way. I recomend saving the rendering.
I ran into this because my development system is django on python 2.4 and I deploy to 2.3. It's a corner case where you use gettext, the
\# -\*- coding: utf-8 -\*-
header and want to have a consistant style in your file.
It is encouraged to use the unicode marker like u'string', but this does not work for __str__ methods of your models as they are called by the ``str'' function and that function again can not handle unicode. It would be really nice to have all unicode intern and only do the appropriated encoding on the output.
Anyway. With this little helper you can clutter your files with _('stirng of heart with € äüöß') ... With the coding directive in the header python 2.4 and gettext can handle this on 2.3 though they can't. So this script adds a parachut to the gettext wrapper that kicks in if gettext is failing.
You're looking at the most-bookmarked snippets on the site; if you'd like to help useful snippets show up here, sign up for an account and you'll get your own bookmarks list.