Skip to content

Instantly share code, notes, and snippets.

@esauro
esauro / admin_actions.py
Created April 25, 2012 15:54
Action to generate a json document with all objects and related objects
# -*- coding: utf-8 -*-
__author__ = 'esauro'
from django.core import serializers
from django.db.models.deletion import Collector
from django.http import HttpResponse
from django.db import router
def export_related_as_json(modeladmin, request, qs):
"""Serializes the selected queryset and all related objects to JSON"""
@esauro
esauro / row_selector.js
Created May 16, 2012 15:51
jQuery selector for table rows o table cols based on http://programanddesign.com/js/jquery-select-table-column-or-row/, modified to make row includes th
<script>
$.fn.row = function(i) {
return $('tr:nth-child('+(i+1)+') td, tr:nth-child('+(i+1)+') th', this);
}
$.fn.column = function(i) {
return $('tr td:nth-child('+(i+1)+')', this);
}
$('table').row(2).hide();