Skip to content

Instantly share code, notes, and snippets.

View alecperkins's full-sized avatar

Alec Perkins alecperkins

View GitHub Profile
@alecperkins
alecperkins / gist:1364430
Created November 14, 2011 16:56
Simulated ForeignKeys from MongoEngine Document to Django Models
# Using the `@property` decorator allows the MongoEngine Document object to have
# properties that reference Models, and be got/set like normal foreign keys.
# This same pattern can work the other way and allow Models interface with
# Documents.
class Foo(mongoengine.Document):
# The `id` of the property is stored in the Document.
user_id = mongoengine.IntField()
# Setters and getters to interface with the SQL DB and set Users to the
@alecperkins
alecperkins / templates.coffee
Created October 21, 2011 15:40
Backbone template…template
###
## Partials
Included in templates using CoffeeScript's string interpolation:
partial = "<partial>content {{ foo }}</partial>"
template = """
<template>
<stuff>#{ partial }</stuff>