djangosnippets.org: Latest snippets posted by oggyhttps://djangosnippets.org/users/oggy/2008-10-03T06:10:44.058539-05:00oggyChunks template filter
2008-10-03T06:10:44.058539-05:00oggyhttps://djangosnippets.org/snippets/1106/<p>A simple filter which divides an iterable (list, tupe, string, etc) in chunks, which can then be iterated over separately. A sample of the filter usage is given: a gallery template in which I needed to display images in a table, three images per row, one row for images followed …</p>
Freely redistributableCSRF this!
2008-09-23T18:21:01.295813-05:00oggyhttps://djangosnippets.org/snippets/1082/<p>A form with built-in CSRF protection. Include CsrfCookieMiddleware in your MIDDLEWARE_SETTINGS, subclass SafeForm and off you go. See:
<a href="http://groups.google.com/group/django-developers/browse_thread/thread/2c33621003992d07?hl=en">this django-developers post</a> for more info.</p>
<p>[edit]
This form is actually WAY overengineered currently. Will update soon.</p>
Freely redistributableCheckedField
2008-09-16T07:26:20.722378-05:00oggyhttps://djangosnippets.org/snippets/1058/<p>Here's a snippet to pair an arbitrary form Field type (the "target field") with a checkbox. If the checkbox is not selected, the cleaned_data value for the field will be None. If the checkbox is selected, it will return the target field's cleaned value.</p>
Freely redistributableRecaptchaForm
2008-06-17T16:54:34.574978-05:00oggyhttps://djangosnippets.org/snippets/812/<p>There already is a <a href="http://www.djangosnippets.org/snippets/433/">snippet on here</a> that shows how to use reCAPTCHA with Django, but being the lazya-- that I am, I wanted the form to:</p>
<ul>
<li>
<p>display the captcha when as_table is used</p>
</li>
<li>
<p>handle captcha validation for me</p>
</li>
</ul>
<p>So RecaptchaForm does the trick. Just subclass from it and voila, …</p>
Freely redistributable