Skip to content

Instantly share code, notes, and snippets.

@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@jacobian
jacobian / deleting_file_field.py
Created March 27, 2011 22:19
DeletingFileField
from django.db import models
from django.db.models import signals
class DeletingFileField(models.FileField):
"""
FileField subclass that deletes the refernced file when the model object
itself is deleted.
WARNING: Be careful using this class - it can cause data loss! This class
makes at attempt to see if the file's referenced elsewhere, but it can get