Bot没有返回一个HttpResponse对象。它返回了None

时间:2017-11-10 21:17:09

标签: python django

我用telebotDjango为电报编写机器人。当我在服务器上运行他并观看完整的日志时,我有下一个文本:

Internal Server Error: /bot/
Traceback (most recent call last):
  File "/home/fishbot/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/fishbot/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 198, in _get_response
    "returned None instead." % (callback.__module__, view_name)
ValueError: The view bot.views.bot didn't return an HttpResponse object. It returned None instead.

有人帮助我吗?

P.S我无法在标签0上附加telebot

1 个答案:

答案 0 :(得分:2)

在Django中,您必须在视图中返回HttpRequest个实例。

尝试做这样的事情:

from django.http import HttpResponse

def current_datetime(request):
    response = '' # Put whatever you want to return in here.
    return HttpResponse(response)