Skip to content

Instantly share code, notes, and snippets.

View wjurkowlaniec's full-sized avatar
🎹

Wojtek Jurkowlaniec wjurkowlaniec

🎹
View GitHub Profile
from django.contrib.admin import FieldListFilter
from django.utils.translation import ugettext as _
class ActiveValueFilter(FieldListFilter):
"""list_filter which displays only the values for a field which are in use
This is handy when a large range has been filtered in some way which means
most of the potential values aren't currently in use. This requires a
queryset field or annotation named "item_count" to be present so it can
//get VALUE/TEXT of select from html, to insert in format ('val','text'),
$('#SELECT_ID').children().each(function(index){console.log("('"+$(this).val() + "', '" + $(this).text()+ "'),");})
@wjurkowlaniec
wjurkowlaniec / mailing.py
Last active August 29, 2015 13:56
Django mailing made easy
# -*- coding: utf-8 -*-
from django.core.mail import send_mail, mail_managers, EmailMultiAlternatives
from django.template.loader import render_to_string
from django.conf import settings
class Mailing:
path_prefix = 'mail/'
path_suffix = '.html'
prefix_title = u"TITLE BEGINNING - "