Login

Snippets by robhudson

Snippet List

Remember path decorator

Decorator that stores the `request.path` URL in a session variable to be used later, e.g. in a "Continue Shopping" link on a cart page. Wrap and view that you want to be able to link back to easily. When those views are called, it updates the session with the current `request.path` value. This can be pulled back out of the session whenever you need to provide a link back from whence the user came.

  • session
  • decorator
Read More

parse date template tag

Return a datetime corresponding to date_string, parsed according to format. I had the need for such a thing while working with an API that returned JSON that I fed, via simplejson, directly to a template, and didn't want to change the data structure just for this one piece.

  • datetime
  • parse
  • strptime
Read More

Use MEDIA_URL in flatpages

This is a template filter to enable the use of the MEDIA_URL setting in content from the flatpages database table. It searches for {{ MEDIA_URL }} and replaces it with that found in your settings. Note: To set up, drop the above code into a file called `media_url.py` in your templatetags directory in one of your INSTALLED_APPS, and add the filter to your flatpages template like so: {% load media_url %} {{ flatpage.content|media_url }}

  • filter
  • flatpages
Read More

HTML Widgets

A simple widget library to provide HTML4 widgets for HTML validation fanatics.

  • html
  • widget
  • html4
Read More

robhudson has posted 4 snippets.