Skip to content

Instantly share code, notes, and snippets.

View dfalk's full-sized avatar

Dmitry Falk dfalk

  • freelancer
  • Russia, Yoshkar-Ola
View GitHub Profile
@h3
h3 / adminthumbnail.py
Created April 16, 2012 04:00
AdminThumbnailMixin
from django.contrib import admin
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from easy_thumbnails.files import get_thumbnailer
class AdminThumbnailMixin(object):
thumbnail_options = {'size': (60, 60)}
thumbnail_image_field_name = 'image'
thumbnail_alt_field_name = None
@dfalk
dfalk / README.rst
Created February 29, 2012 11:39
Using django-floppyforms with django-sekizai

This is a bridge between django-floppyforms and django-sekizai.

This lets you define custom floppyforms widgets and move the css / js parts to the top or the bottom of the page.

Just write a floppyforms widget with a custom template. In that template, use {% addtoblock "js" %} to inject some data in a sekizai block. In the template that renders your form, make sure you use iterate over your fields and use {% widget field %} to render instead of {{ field }}.

Note that to render your widget separately in the console, you'll need to add enable_sekizai in one of your app's templatetags and do {% load enable_sekizai %}{% enable_sekizai %}. Note that anything inside the {% addtoblock %} tags will disappear but your widgets can be rendered in the console.

Not sure this plays well with hidden widgets. Use at your own risk.

@timmyomahony
timmyomahony / postprocess_sekizai.py
Created October 25, 2011 01:11
django-sekizai postprocessor for enabling django-compressor compatibility
"""
Get django-sekizai, django-compessor (and django-cms) playing nicely together
re: https://github.com/ojii/django-sekizai/issues/4
using: https://github.com/jezdez/django_compressor.git
and: https://github.com/ojii/django-sekizai.git@0.5
"""
from compressor.templatetags.compress import CompressorNode
from django.template.base import *
def compress(data, name):
@dokterbob
dokterbob / admin.py
Created February 16, 2011 16:29
Django Admin mixins for dynamic TinyMCE link and image lists.
from django.core.urlresolvers import reverse
from sorl.thumbnail import get_thumbnail
from django.conf.urls.defaults import patterns, url
# This nice little snippet makes the life of someone extending the admin
# functionality a lot easier.
# Find the original at: http://djangosnippets.org/snippets/1804/