This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
# How to add a field to the Django Admin Add User form | |
# using UserCreationForm. Add this to a admin.py and alter | |
# to whatever fields you'd like | |
from django.contrib.auth.forms import UserCreationForm | |
from django.contrib.auth.models import User | |
from django.contrib.auth.admin import UserAdmin | |
from django import forms | |
from django.utils.translation import ugettext_lazy as _ | |
from django.contrib import admin |
""" | |
Came up with this for satchmo's downloadable product migration, 0001_split. | |
""" | |
def db_table_exists(table, cursor=None): | |
try: | |
if not cursor: | |
from django.db import connection | |
cursor = connection.cursor() | |
if not cursor: | |
raise Exception |
# Template: A.html | |
<html> | |
<head></head> | |
<body> | |
{% block hello %} | |
HELLO | |
{% endblock %} | |
</body> | |
</html> |
#!/bin/sh | |
cd ~/proj/root | |
tmux new-session -d -s pdev | |
tmux new-window -t pdev:1 -n shell | |
tmux rename-window -t pdev:1 "shell" | |
tmux send-keys -t pdev:1 "workon pdev" Enter "PS1=\$_OLD_VIRTUAL_PS1" Enter "clear" Enter |
git diff --name-only | uniq | xargs mvim
When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.
Once you're in Vim, you can then switch between the files with :n
and :prev
, or another favourite: :w | n
(save current file and open the next command line-supplied file).
UPDATE: see below for a version that works with real terminal commands.
<?php | |
// Machine name for our custom node | |
define('NODE_NAME', 'the_node_machine_name'); | |
// Machine name for our custom taxonomy | |
define('TAXONOMY_NAME', 'the_taxonomy_machine_name'); | |
function module_install() { | |
_create_taxonomy(); | |
_create_content_type(); | |
} |
/** | |
* EXAMPLE FEATURE UPDATE | |
* Enable and revert the my_new_feature_name feature. | |
*/ | |
function example_update_7001() { | |
// An array of new or changed features; the array keys are feature names, | |
// values are an array of exportable types as seen in a feature's .info file: | |
// features[field][] = node-page-body | |
$features = array( | |
'my_new_feature_name' => array('field', 'variable'), |
Taken from Using MacOSX Lion command line mail with Gmail as SMTP
Edit file /etc/postfix/main.cf
sudo vim /etc/postfix/main.cf
from contextlib import contextmanager | |
""" | |
Usage: | |
with env_var('MY_VAR', 'foo'): | |
# is set here | |
# does not exist here | |
""" |