Friday, March 2, 2012

Traceback from csrf_exempt in 1.3.1

I have never used csrf_exempt before. I keep experiencing a traceback
with 1.3.1, which may be self-induced. Here is my views file:

auth/views.py
from django.http import HttpResponse
from django.utils import simplejson
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def json_api(request):
return HttpResponse(simplejson.dumps(request),
mimetype="application/json")

When I do a curl:

curl -i -X POST -d '{"screencast":{"subject":"tools"}}' http://127.0.0.1:8000/auth/

I experience 500 Internal Server Error:

Traceback (most recent call last):

File "/Library/Python/2.7/site-packages/django/core/servers/
basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)

File "/Library/Python/2.7/site-packages/django/core/handlers/
wsgi.py", line 272, in __call__
response = self.get_response(request)

File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())

File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 218, in handle_uncaught_exception
return callback(request, **param_dict)

File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

File "/Library/Python/2.7/site-packages/django/views/defaults.py",
line 30, in server_error
t = loader.get_template(template_name) # You need to create a
500.html template.

File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 157, in get_template
template, origin = find_template(template_name)

File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 138, in find_template
raise TemplateDoesNotExist(name)

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment