Skip to content

Instantly share code, notes, and snippets.


Rey Abolofia purple4reina

  • Stitch Fix
  • Portland, OR
View GitHub Profile
purple4reina /
Last active Aug 29, 2015
Django Safe Template
from django.template import Template
class SafeTemplate(Template):
Subclass of the regular django Template but disallows rendering anything
that will call a method on a class thus making it safe for use as a user
editable object
# this will return the template as expected
purple4reina /
Created Jun 9, 2015
Running Django Unit Tests
#!/usr/bin/env python
Run all unit tests within the current working directory optionally skipping
some modules
This script should be used instead of running `./ test`. This django
provided unittest runner does not reset the testing database between each
testing file. The only way to ensure the testing database is completely dropped
is by running each test file individually.
class throttle(object):
Decorator that prevents a function from being called more than once every
time period. If called too soon, RuntimeError is raised.
To create a function that cannot be called more than once a minute:
def my_fun():
You can’t perform that action at this time.