Login

Tag "processor"

Snippet List

Use MEDIA_URL in flatpages with SSL

This is a copy of [snippet 654](http://djangosnippets.org/snippets/654/), modified to allow dynamic MEDIA_URL, as you might need that for SSL in combination with [snippet 1754](http://djangosnippets.org/snippets/1754/). 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 the current MEDIA_URL added by a context processor. 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:MEDIA_URL }}

  • filter
  • ssl
  • context
  • flatpages
  • processor
Read More

Load static media from secure (SSL) static server (Context Processor)

If you request static files such as images, javascript or css using http rather than https, the browser will complain that your site is not secure. This simple context processor will replace http:// with https:// in your MEDIA_URL if your static files are being included from an https page. In your settings.py just replace 'django.core.context_processors.media' with your new context processor.

  • files
  • ssl
  • context
  • static
  • processor
  • secure
  • content
  • media_url
Read More

Letterbox for sorl-thumbnail

This custom processor is meant for use with sorl-thumbnail to add letterboxing functionality. Add to your THUMBNAIL_PROCESSORS like so: `THUMBNAIL_PROCESSORS = ( 'sorl.thumbnail.processors.colorspace', 'sorl.thumbnail.processors.autocrop', 'sorl.thumbnail.processors.scale_and_crop', 'sorl.thumbnail.processors.filters', # custom processors 'utils.processors.ltbx', ) ` and then use in your templates like so: ` {% thumbnail model.img_field 200x150 ltbx as thumb %} <img src="{{ thumb }}" width="{{ thumb.width }}" height="{{ thumb.height }}" />` Enjoy.

  • image
  • processor
  • sorl
Read More

Dynamic Django settings context processor

Here's a nice way of easily passing only certain settings variables to the template. Because of the way Django looks up context processors, we need a little hack with sys.modules. The [blog entry is here](http://sciyoshi.com/blog/2008/jul/10/dynamic-django-settings-context-processor/).

  • dynamic
  • settings
  • context
  • processor
Read More

4 snippets posted so far.