Skip to content

Instantly share code, notes, and snippets.

Avatar

Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

View GitHub Profile
@vinidmpereira
vinidmpereira / example_current_user.py
Last active May 21, 2019
get_current_user middleware.
View example_current_user.py
"""
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()
@EBNull
EBNull / relations.py
Created Aug 17, 2011
Returns all foreign key relations to a django model and their accessors
View relations.py
#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
gcko / related.py
Last active Oct 24, 2020
Django Custom Model ForeignKey Field for Spanning Databases
View related.py
You can’t perform that action at this time.