Simon Willison’s Weblog

Subscribe
Atom feed for django-snippets

6 items tagged “django-snippets”

2008

RestView—a class for creating a view that dispatches based on request.method (via) I finally got around to writing up a simple approach I’ve been using for REST-style view functions in Django that dispatch based on request.method.

# 21st September 2008, 8:47 pm / restview, django, python, rest, restful, views, django-snippets

Django snippets: Sign a string using SHA1, then shrink it using url-safe base65. I needed a way to create tamper-proof URLs and cookies by signing them, but didn’t want the overhead of a full 40 character SHA1 hash. After some experimentation, it turns out you can knock a 40 char hash down to 27 characters by encoding it using a custom base65 encoding which only uses URL-safe characters.

# 27th August 2008, 10:18 pm / django-snippets, django, python, hashes, sha1, base65, cryptography, security, cookies, signedcookies, urls

Django snippets: Command to dump data as a python script. Extremely useful—dumps the data for an application as an executable Python script which will re-import it in to another database without any risk of colliding with existing IDs, sorting out foreign keys along the way.

# 24th June 2008, 12:07 pm / django, python, import, django-snippets

views.py for wikinear.com (via) I’ve published the views.py file from wikinear.com as an example of simple Fire Eagle integration with a Django application.

# 22nd March 2008, 7:23 pm / fireeagle, django, python, django-snippets, wikinear

Django snippets: “for” template tag with support for “else” if array is empty. A neat solution to a common pattern; I’d personally like to see this included in Django proper.

# 16th January 2008, 9:42 pm / django, python, templating, django-snippets

2007

Django snippets. James Bennett’s new site for Django snippets. The source code to the whole site is available.

# 26th February 2007, 10:08 am / django, django-snippets, james-bennett, python