Reputation: 15808
I recently started to learn Django and found it amazingly useful. But there is one problem: I have no idea how to debug a website properly!
For example, I downloaded some examples and tried to set them up. But when I visit the site, I got this traceback. This is not helpful at all -- I get that Python is complaining "str object is not callable". But how is it triggered? What did I do that result in that function call?
Is there an easy way to debug Django website?
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4.3
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'forum',
'registration')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
Exception Type: TypeError at /
Exception Value: 'str' object is not callable
Upvotes: 2
Views: 127
Reputation: 48730
The stack trace you've shown us isn't the entire stacktrace, it's just where the error was generated. The django default debug page allows you to interactively expand nodes within the trace to see where the error first originated from. Go up a few levels, and find the most likely suspect - a line number within your own code - and investigate from there.
Later, django-debug-toolbar is an extremely useful app for seeing a vast amount of information to help in debugging.
Upvotes: 1