Skip to content

Instantly share code, notes, and snippets.

@keningle
keningle / decorator.py
Created July 2, 2013 19:43
Example of how to pass URL parameters to a decorator in Django
from django.utils.functional import wraps
...
def check_company_admin(view):
@wraps(view)
def inner(request, slug, *args, **kwargs):
# Get the company object
company = get_object_or_404(Company, slug=slug)
# Check and see if the logged in user is admin
@keningle
keningle / gist:5225855
Created March 23, 2013 00:53
Setting needed when deploying a django application to webfaction
ALLOWED_HOSTS = ['www.example.com',]
@keningle
keningle / gist:4582308
Created January 20, 2013 22:37
Check to see if function exists in PHP.
if (function_exists('function_name')) {
function_name()
}