Skip to content

Instantly share code, notes, and snippets.

View baldurthoremilsson's full-sized avatar

Baldur Þór Emilsson baldurthoremilsson

View GitHub Profile
@baldurthoremilsson
baldurthoremilsson / README.md
Created October 10, 2012 14:40
HTTPS enforced in Django

HTTPSMiddleware for Django

About

This middlware enforces HTTPS for logged in users and HTTP for others. This can be overridden with the require_https view decorator, which always enforces HTTPS.

@baldurthoremilsson
baldurthoremilsson / README.md
Created July 30, 2012 14:29
File hash GET parameters for Django staticfiles

About

A class for the static files app in Django that invalidates outdated browser cache.

How to use

You add the line

STATICFILES_STORAGE = 'path.to.hashpathstaticfilesstorage.HashPathStaticFilesStorage'
# -*- coding: utf-8 -*-
class LazyMapperItem(object):
def __init__(self, item, mapping):
self.__item = item
self.__mapping = mapping
def __getattr__(self, name):
try:
real_name = self.__mapping[name]