This file contains 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
import uuid | |
import requests | |
from django.core.files.base import ContentFile | |
from django.db import models | |
from django.db.models.fields.files import ImageFileDescriptor, ImageFieldFile | |
class UrlImageFileDescriptor(ImageFileDescriptor): | |
def __init__(self, field): |
This file contains 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
from django.db.models.signals import pre_delete, post_save | |
from django.contrib.admin.models import LogEntry, DELETION, ADDITION, CHANGE | |
from django.utils.encoding import force_text | |
##Django admin | |
def get_content_type_for_model(obj): | |
return ContentType.objects.get_for_model(obj) | |
import inspect | |
from django.core.handlers.wsgi import WSGIRequest |
This file contains 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
from django.db.models.signals import pre_save, pre_delete | |
from django.contrib.admin.models import LogEntry, DELETION, ADDITION, CHANGE | |
from django.utils.encoding import force_text | |
##Django admin | |
def get_content_type_for_model(obj): | |
return ContentType.objects.get_for_model(obj) | |
import inspect | |
from django.core.handlers.wsgi import WSGIRequest |
This file contains 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
#Encontrado en Google https://groups.google.com/forum/#!topic/django-users/RM7ZZ9naNQA | |
def obtener_request(): | |
try: | |
user = None | |
outer_frames = inspect.getouterframes(inspect.currentframe()) | |
for tpl in outer_frames: | |
arginfo = inspect.getargvalues(tpl[0]) | |
if(type(arginfo[3]) is dict): | |
arg_dict = arginfo[3].copy() | |
for k in arg_dict: |
This file contains 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
from django.contrib.contenttypes.fields import GenericForeignKey | |
from django.contrib.contenttypes.models import ContentType | |
class Log_Entry_General(models.Model): | |
mensaje = models.CharField() | |
content_type = models.ForeignKey(ContentType) | |
object_id = models.PositiveIntegerField() | |
object = Generic.ForeignKey('content_type', 'object_id') |
This file contains 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
import csv | |
data = list() | |
with open('Base.csv', 'rU') as f: | |
reader = csv.DictReader(f, quotechar='|', quoting=csv.QUOTE_MINIMAL) | |
for row in reader: | |
for (k,v) in row.items(): | |
z = k.replace('\t', ",") | |
n = v.replace('\t', ",") | |
num = {str(reader.line_num):(z.split(','), n.split(','))} |
This file contains 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
from django.contrib import admin | |
class MiAdmin(model.Admin): | |
def get_queryset(self, request): | |
qs = Model.objects.filter(usuario=request.user) ###NO PONGAS [0] porque si no dara error en al base de datos debido a que [0] devuelve un modelo no un queryset, por eso se llama get_queryset | |
ordering = self.get_ordering(request) | |
if ordering: | |
qs = qs.order_by(*ordering) |
This file contains 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
{ | |
:+ | |
{:app | |
#{:lt.objs.clients.local/startup-with-local-client | |
:lt.objs.sidebar.workspace/workspace.open-on-start | |
:lt.objs.settings2/load-behaviors | |
:lt.objs.settings2/load-keys | |
:lt.objs.settings2/create-user-settings | |
:lt.objs.proc/set-path-OSX | |
:lt.objs.workspace/reconstitute-last-workspace |
This file contains 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
$(document).ajaxSend(function(event, xhr, settings) { | |
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie !== '') { | |
var cookies = document.cookie.split(';'); | |
for (var i = 0; i < cookies.length; i++) { | |
var cookie = jQuery.trim(cookies[i]); | |
// Does this cookie string begin with the name we want? | |
if (cookie.substring(0, name.length + 1) == (name + '=')) { | |
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
This file contains 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
$(document).ajaxSend(function(event, xhr, settings) { | |
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie !== '') { | |
var cookies = document.cookie.split(';'); | |
for (var i = 0; i < cookies.length; i++) { | |
var cookie = jQuery.trim(cookies[i]); | |
// Does this cookie string begin with the name we want? | |
if (cookie.substring(0, name.length + 1) == (name + '=')) { | |
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |