Traceback (most recent call last): File "C:\Python34\lib\site-packages\django-1.10.6-py3.4.egg\django\core\handlers\exception.py", line 42, in inner response = get_response(request) File "C:\Python34\lib\site-packages\django-1.10.6-py3.4.egg\django\core\handlers\base.py", line 198, in _get_response "returned None instead." % (callback.__module__, view_name) ValueError: The view music.views.favorite didn't return an HttpResponse object. It returned None instead. [11/Mar/2017 15:34:57] "POST /music/1/favorite/ HTTP/1.1" 500 56886
答案 0 :(得分:0)
那是因为在你的else
条款中,你没有返回任何东西!您只是保存selected_song
。您应该返回一个HttpResponse对象(即通常使用render
或HttpResponseRedirect
)