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.
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.
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.
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.
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.
2007
Django snippets. James Bennett’s new site for Django snippets. The source code to the whole site is available.