0

Trying to mimic the first answer in this post and create a log_error decorator: Log all errors to console or file on Django site

Here is the error that I get:

raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().

Maybe I'm not supposed to put this function in views.py or maybe this doesn't work in Django 2.2.3?

def log_error(func):
 def _call_func(*args, **argd):
    try:
        func(*args, **argd)
    except:
        print("error") #substitute your own error handling
    return _call_func
  • The problem is not in the code you have posted. Show your urls and the view where you are using this decorator. – Daniel Roseman Aug 17 '19 at 13:05
  • 1
    (Note, however, that there's no need to do this at all; you can configure Django itself to log errors to the console by using the LOGGING setting. – Daniel Roseman Aug 17 '19 at 13:06

0 Answers0