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
AppState = new Backbone.Model | |
domain: null | |
class Domain extends Backbone.Model | |
class DomainCollection extends Backbone.Collection | |
model: Domain |
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
class Author(models.Model): | |
first_name = models.CharField(max_length=30) | |
last_name = models.CharField(max_length=30) | |
author = Author('John', 'Doe') | |
author.save() |
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
author.pk = None | |
author.save() | |
author.pk # 2 |
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
class Book(models.Model): | |
title = models.CharField(max_length=50) | |
author = models.ForeignKey(Author) | |
summary = models.TextField() | |
pub_date = models.DateField() | |
book = Book('John Doe: The Autobiography', author, | |
'A long, long time ago..', date(2011, 9, 3)) | |
book.save() |
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
class Book(models.Model): | |
author = models.OneToOneField(Author) | |
... |
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
class Book(models.Model): | |
authors = models.ManyToManyField(Author) | |
... |
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
authors = book.authors.all() | |
book.pk = None | |
book.save() | |
book.authors = authors |
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
# Add: | |
# | |
# STATICFILES_FINDERS = ( | |
# 'path.to.this.module.PrefixedAppDirectoriesFinder', | |
# ... | |
# ) | |
from django.contrib.staticfiles.finders import AppDirectoriesFinder | |
from django.contrib.staticfiles.storage import AppStaticStorage |
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
<VirtualHost *:80> | |
# Define a conventional location for where are apps are deployed | |
# Locations such as "/apps/foo" and "/apps/bar" will match result | |
# in "foo" and "bar", respectively, being the application "names". | |
WSGIScriptAliasMatch ^/apps/([^/]+) /usr/local/srv/apps/$1-env/$1/src/conf/wsgi/app.py | |
# This example derived from deployed multiple Django applications, thus | |
# the static and media directories are mapped here. | |
AliasMatch ^/apps/([^/]+)/static/(.*) /usr/local/srv/apps/$1-env/$1/src/_static/$2 |
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
# Inspired by http://code.activestate.com/recipes/576567/ | |
import time | |
from django.core.cache import get_cache, DEFAULT_CACHE_ALIAS | |
class cache_queue(object): | |
"A context manager for queuing Django cache operations." | |
poll_interval = 0.005 # in seconds |
OlderNewer