Login

Snippets by robertrv

Snippet List

django redirects middleware a bit more fleixble

This is replace for django.contrib.redirects.RedirectFallbackMiddleware which redirects exact matches as well as startswith matches for the redirect.old_path I had a problem with my urls, because are dynamically generic, so I can't create one redirect entry on the database for each possible url. So I made django redirects to search any redirect with the exact match or any database entry being the head of my url, for example: I have django redirects which redirects /calendars/3434/ --> / . But when I have a 404 on /calendars/3434/c/2009/10/23/ now it redirects properly. So my redirects now acts as /calendars/3434/*

  • generic
  • redirects
  • contrib
Read More

More flexible "Partial Template"

This is an extension of the snippet http://www.djangosnippets.org/snippets/1302/ to make it a bit more flexible and been able pass more than one parameter to our "Partial Template". To use it you can {% partial_template template_name param1:variable1 param2:variable2 ... %} or: {% partial_template partials/mini_template.html item:data1 var2:"False" var3:"2*2" %}

  • template
  • templatetag
  • include
Read More

robertrv has posted 2 snippets.