Skip to content

Instantly share code, notes, and snippets.


Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

  • Palmas, Tocantins, Brasil
View GitHub Profile
EBNull /
Created Aug 17, 2011
Returns all foreign key relations to a django model and their accessors
#Some utilities to work with django models and foreign keys.
#Especially useful for finding (and writing out) code to illuminate information about relations.
#To try it out, run show_relation_accessors(model) in a python prompt, or to be more general, get_related_instance_ids_code(model)
#-2011 CBWhiz
#Usage sample:
# from django.db import transaction
gcko /
Last active Mar 26, 2021
Django Custom Model ForeignKey Field for Spanning Databases
vinidmpereira /
Last active May 21, 2019
get_current_user middleware.
This should be a separate file, i usually install it on the maind django project folder.
from threading import local
from django.utils.deprecation import MiddlewareMixin
_user = local()