An Another solution with Middleware and save rewriting :
With middleware solution You can call "request" everywhere.
""" Middleware """
# coding: utf-8
from django.utils.thread_support import currentThread
_requests = {}
def get_request():
return _requests[currentThread()]
class GlobalRequestMiddleware(object):
def process_request(self, request):
_requests[currentThread()] = request
""" save Rewrinting """
class Production(models.Model):
creator = models.ForeignKey(User, related_name = "%(class)s_creator")
creation_date = models.DateTimeField(auto_now_add = True)
modification_date = models.DateTimeField(auto_now = True)
def save(self, force_insert = False, force_update = False):
self.creator = get_request().user
super(Production, self).save(force_insert = force_insert, force_update = force_update)
return