This file contains hidden or 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
# Convert Existing App | |
$ python manage.py convert_to_south APP_NAME --settings settings_debug | |
# Perform model change on development | |
$ python manage.py schemamigration APP_NAME --auto --settings settings_debug | |
$ python manage.py migrate APP_NAME --settings settings_debug.py | |
# Perform change on live server (assumes migration was applied and checked in on development) |
This file contains hidden or 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.http import HttpResponse | |
from django.template.loader import render_to_string | |
from django.utils import simplejson | |
def myajax(request): | |
#Some logic | |
html = render_to_string(TEMPLATE, context) | |
return HttpResponse(simplejson.dumps({"html": html}), | |
content_type="application/json; charset=utf-8") |
This file contains hidden or 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
Work out total and then round up to 2 decimal places WITHOUT dropping the final zero.... | |
from decimal import * | |
cost = "12.56896" | |
cost = Decimal(cost).quantize(Decimal('.01'), rounding=ROUND_UP) |
This file contains hidden or 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
MAMP: | |
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot | |
set global net_buffer_length=1000000; | |
set global max_allowed_packet=1000000000; | |
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot < ~/Downloads/DUMP | |
This file contains hidden or 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 BeautifulSoup import BeautifulSoup | |
body = "<p>Dear Everyone,</p><p>This is a test</p><h1>Test Complete</h1>" | |
plain_text = ' '.join(BeautifulSoup(body).findAll(text=True)) |
NewerOlder