What is the django way to print debug messages? [duplicate]

Suppose I have this function in views.py in Django.

def test_func(request, username):
    print("print debug msg in test_func()")
    # other code 

Using print() doesn't look like a good way to print out debug messages because the messages will be printed out even in production mode. How do I write debug messages on Django so that the messages will only be printed out in DEBUG mode?

I am using Django 4.1

Back to Top