Skip to content

Instantly share code, notes, and snippets.

View AndrewJHart's full-sized avatar
:electron:
Building react apps & micro-services

Andrew Hart AndrewJHart

:electron:
Building react apps & micro-services
View GitHub Profile
def save_m2m(self, bundle):
"""
Handles the saving of related M2M data.
Due to the way Django works, the M2M data must be handled after the
main instance, which is why this isn't a part of the main ``save`` bits.
Currently slightly inefficient in that it will clear out the whole
relation and recreate the related data as needed.
"""
from django.db import models
import uuid
class UUIDField(models.CharField):
"""
A field which stores a UUID value in hex format. This may also have
the Boolean attribute 'auto' which will set the value on initial save to a
new UUID value (calculated using the UUID1 method). Note that while all
UUIDs are expected to be unique we enforce this with a DB constraint.
@import 'jeet'
edit()
section
center()
background red
article
col(2/4, offset: 1/4)
background orange
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@AndrewJHart
AndrewJHart / app.js file
Created July 16, 2013 17:42 — forked from saniko/app.js file
Sample Backbone + Marionette + require-js AMD javascript app
define([
'jquery',
'underscore',
'backbone',
'marionette',
'handlebars',
'text!templates/app_view.html',
'modules/mainMenuView/mainMenuView',