limodou wrote: > 2005/11/17, plisk <[EMAIL PROTECTED]>: > > > > Hi there. > > > > Seems like its not possible to access request object in hooks like > > pre_save and display methods(those are listed in list_display) ? Is it > > supposed to be like this by design ? If so then hardly its very > > convinient to use in real applications. For example, i would like to > > get server address and port in post_save hook, current logged in user > > in display method and so on.. > > > > Or maybe there is the way ? > > > > > > May be middleware can do this. But I'm not sure.
Yeah, finally came up with this dirty hack as a middleware from django.core import meta import django.models.intranet class ModelsAddRequest: def process_request(self, request): for x in dir(django.models.intranet): klass = django.models.intranet.__dict__[x] if isinstance(klass, meta.ModelBase): klass.request = request return None