thanks Margie, I already did with the info you gave me Tom. 2011/3/16 Margie Roginski <margierogin...@yahoo.com>
> I found the basics for this by googling around, and I can't remember > where I got it, but thanks to whomever gave me the basics because it > is very useful. Put this in your middleware and it will make the mail > that you receive have the name of the user and their email: > > class ExceptionUserInfoMiddleware(object): > """ > Adds user details to request context on receiving an exception, so > that they show up in the error emails. > Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on > top if possible). This allows > it to catch exceptions in other middlewares as well. > > """ > > def process_exception(self, request, exception): > """ > Process the exception. > > :Parameters: > - `request`: request that caused the exception > - `exception`: actual exception being raised > """ > > try: > if request.user.is_authenticated(): > request.META['USERNAME'] = str(request.user.username) > request.META['USER_EMAIL'] = str(request.user.email) > else: > request.META['USERNAME'] = "UNKNOWN" > request.META['USER_EMAIL'] = "UNKNOWN" > except: > request.META['USERNAME'] = "UNKNOWN" > request.META['USER_EMAIL'] = "UNKNOWN" > pass > > And for the record, I of course agree that being able to google and > then adapt things is very important. But this is a common need so it > seems worthwhile to post it explicitly to help the django community. > > Margie > > > On Mar 16, 11:49 am, Shawn Milochik <sh...@milochik.com> wrote: > > On Wed, Mar 16, 2011 at 2:47 PM, emonk <elmonke...@gmail.com> wrote: > > > I'm tired of searching and found many examples of middleware but not > the one > > > I seek > > > > You almost certainly will not find the exact code you need to cut & > > paste. You need to read the examples you did find and learn something. > > Use that knowledge to write what you need. That's what the rest of us > > do. > > > > Shawn > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.