Login

Snippets by gonz

Snippet List

Template tags/filter for working with query strings

Some template tags/filter for working with query strings in templates. Examples: {% load qstring %} {% qstring %} # Prints current request's query string {% qstring as current_qstring %} # Same but goes to context {{ current_qstring|qstring_del:"key1" }} # Deletes all key1 values {{ current_qstring|qstring_del:"key1&key2" }} # Deletes all key1 and key2values {{ current_qstring|qstring_set:"key1=1&key2=2" }} # Deletes all old key1 and key2 values and adds the new values.

  • templatetag
  • string
  • query
Read More

URL redirects middleware

Sometimes you need to make redirects that involve domains, you can't define those on the site urls, this middleware lets you define multiple redirects on your site settings. Note: *You also can use the web server to do this, but I have found this middleware a useful tool to quickly or temporarily define redirects*. Depending on your needs you may also find useful [snippet 434](http://www.djangosnippets.org/snippets/434/).

  • middleware
  • url
  • redirect
  • domain
Read More

gonz has posted 4 snippets.