下面的代码块抛出一个错误,我不知道为什么——我根本没有改变它——这个错误突然开始发生:
def product_feed(request):
""" Return all site activity from friends, etc. """
if request.user.is_authenticated():
return HttpResponseRedirect("/about/what_next/")
else:
return render_to_response("homepage.html", {}, context_instance=RequestContext(request))
这是它返回的最后一行 render_to_response 是问题发生的地方。
错误是:
Exception Type: SyntaxError at /
Exception Value: invalid syntax (views.py, line 804)
屏幕截图也显示了该问题。
追溯:
Traceback:
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/NB/Desktop/store/views.py" in product_feed
261. return render_to_response("homepage.html", {}, context_instance=RequestContext(request))
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
176. return t.render(context_instance)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
62. return self.nodelist.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/loader_tags.py" in render
123. return compiled_parent._render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
62. return self.nodelist.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/loader_tags.py" in render
123. return compiled_parent._render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
62. return self.nodelist.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/defaulttags.py" in render
281. return nodelist.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/base.py" in render
823. bit = self.render_node(node, context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/template/defaulttags.py" in render
411. url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
363. possibilities = self.reverse_dict.getlist(lookup_view)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
276. self._populate()
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
253. for name in pattern.reverse_dict:
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
276. self._populate()
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
265. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback
216. self._callback = get_callable(self._callback_str)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/utils/functional.py" in wrapper
27. result = func(*args)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable
92. lookup_view = getattr(import_module(mod_name), func_name)
File "/Users/NB/Desktop/myenv2/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: SyntaxError at /
Exception Value: invalid syntax (views.py, line 804)