This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Context(models.Model): | |
name = models.CharField(error_messages={'unique': u'My custom message'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unique_error_message(self, model_class, unique_check): | |
if model_class == type(self) and unique_check == ('field1', 'field2'): | |
return 'Your custom error message.' | |
else: | |
return super(YourModel, self).unique_error_message(model_class, unique_check) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
class JsonAsHTML(object): | |
''' | |
View a JSON response in your browser as HTML | |
Useful for viewing stats using Django Debug Toolbar | |
This middleware should be place AFTER Django Debug Toolbar middleware | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install and select | |
sudo port install postgresql93-server | |
sudo port select --set postgresql postgresql93 | |
# load at startup | |
sudo port load postgresql93-server | |
# create the default database | |
sudo mkdir -p /opt/local/var/db/postgresql93/defaultdb | |
sudo chown postgres:postgres /opt/local/var/db/postgresql93/defaultdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install | |
sudo port install tomcat6 | |
# add -Djava.awt.headless=true to /opt/local/share/java/tomcat6/bin/tomcatctl (line 65) | |
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true" | |
# without this you’ll get this error in /opt/local/share/java/tomcat6/logs/catalina.err: | |
# 2013-11-16 23:39:17.389 jsvc[1698:203] Apple AWT Java VM was loaded on first thread -- can't start AWT. | |
# Nov 16, 2013 11:39:17 PM org.apache.catalina.startup.Bootstrap initClassLoaders | |
# SEVERE: Class loader creation threw exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo npm -g install yuglify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COMPRESS_YUGLIFY_BINARY = 'yuglify' # assumes yuglify is in your path | |
COMPRESS_YUGLIFY_CSS_ARGUMENTS = '--terminal' | |
COMPRESS_YUGLIFY_JS_ARGUMENTS = '--terminal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from compressor.conf import settings | |
from compressor.filters import CompilerFilter | |
class YUglifyFilter(CompilerFilter): | |
command = "{binary} {args}" | |
def __init__(self, *args, **kwargs): | |
super(YUglifyFilter, self).__init__(*args, **kwargs) | |
self.command += ' --type=%s' % self.type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Old | |
COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter', 'compressor.filters.yui.YUICSSFilter'] | |
# New | |
COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter', 'app.compressor.filters.YUglifyCSSFilter'] | |
# Old | |
COMPRESS_JS_FILTERS = ['compressor.filters.jsmin.SlimItFilter'] | |
# New |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
# This will make sure the app is always imported when | |
# Django starts so that shared_task will use this app. | |
from .celery import app |