- generate an empty migration
- move the migration from
old_app
tonew_app
- edit the migration file to change all instances of
old_app
tonew_app
- add a forward migration to rename the table from
something
tosomething_else
- add a backward migration to do the opposite
- move models.py from
old_app
tonew_app
- apply the migration
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 selenium import webdriver | |
def select_from_chosen(driver, id, value): | |
chosen = driver.find_element_by_id(id + '_chzn') | |
results = chosen.find_elements_by_css_selector(".chzn-results li") | |
found = False | |
for result in results: | |
if result.text == value: |
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
* { | |
font-size: 12pt; | |
font-family: monospace; | |
font-weight: normal; | |
font-style: normal; | |
text-decoration: none; | |
color: black; | |
cursor: default; | |
} |
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
(function( $ ) { | |
$.fn.simulateDragDrop = function(options) { | |
return this.each(function() { | |
new $.simulateDragDrop(this, options); | |
}); | |
}; | |
$.simulateDragDrop = function(elem, options) { | |
this.options = options; | |
this.simulateEvent(elem, options); | |
}; |
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
# Written by Senko Rasic <[email protected]> | |
# Released into Public Domain. Use it as you like. | |
from django.db import models | |
class SingletonModel(models.Model): | |
"""Singleton Django Model | |
Ensures there's always only one entry in the database, and can fix the |
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
# Problem: | |
# | |
# If you use git submodules linking two private github repos, you'll need to create a separate deploy key for each. | |
# Multiple keys are not supported by Ansible, nor does ansible (when running git module) resort to your `.ssh/config` file. | |
# This means your ansible playbook will hang in this case. | |
# | |
# You can however use the ansible git module to checkout your repo in multiple steps, like this: | |
# | |
- hosts: webserver | |
vars: |
I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.
- Publishing (Draft->Approved->Published->Expired->Deleted)
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 CustomTask(Task): | |
def on_failure(self, exc, task_id, args, kwargs, einfo): | |
info = '[{0}] failed: {1}'.format(task_id, exc) | |
logger.exception(info, exc_info=exc) | |
super(CustomTask, self).on_failure(exc, task_id, args, kwargs, einfo) | |
def on_success(self, retval, task_id, args, kwargs): | |
global app | |
if app.is_warm_shutdown: | |
app.consumer.connection._default_channel.do_restore = False |
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
# coding: utf-8 | |
from __future__ import unicode_literals | |
import os | |
from pdfminer.pdfdocument import PDFEncryptionError | |
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter | |
from pdfminer.converter import TextConverter | |
from pdfminer.layout import LAParams | |
from pdfminer.pdfpage import PDFPage | |
from cStringIO import StringIO |