Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Some usefull hacks based on sorl-thumbnail

Project Description

create_thumbs template tag

Parse your text on fly, finds images urls and replace it by thumb url:

{% load sorl_hacks %}

{% for text_block in post.blocks.all %}
    <h4>{{ text_block }}</h4>
    <p>{{ text_block.body|create_thumbs|safe }}</p>
{% endfor %}


Admin model mixin with post_save replacing.

from sorl_hacks.admin import ThumbedCkeditorImages

class BlogPostAdmin(ThumbedCkeditorImages):


Usefull in stadart Django templates. Add property my_model.get_thumb_WIDTHxHEIGHT to yours models.

Example of my_model_detail.html:

{{ my_model.get_thumb_200x200.html }}

{{ my_model.get_thumb_small.html }}

instead of:

{% thumbnail my_model.pic "56x56" crop="center" as im %}
    <img src="{{ im.url }}" width="56" height="56">
{% empty %}
    <img src="{{ MISSING_IMAGE }}" width="56" height="56">
{% endthumbnail %}



from django.db import models
from sorl.thumbnail import ImageField
from sorl_hacks.models import ThumbMixin

class Post(ThumbMixin, models.Model):
    image = ImageField('image', upload_to='posts', **nullable)

Release History

This version
History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(4.9 kB) Copy SHA256 Hash SHA256
Source None Sep 3, 2014

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting