我试图使用Django消息显示消息,但当@shared_任务上发生某个事件时,应执行此警报。 这是tasks.py中的芹菜函数代码
def show_message_in_time(self,response):
while True:
# get_info_to_show() this function will do something
messages.info(response, 'Your email is added successfully!')
sleep(2*60)
这是views.py上的函数
def index(response):
show_message_in_time.delay(response)
return render(response, "Sales.html", {'zipped_list': objs})
下面是我收到的错误
Exception Value:
Object of type 'WSGIRequest' is not JSON serializable
我曾尝试将WSGIRequest转换为JSON,但也没有成功。 任何帮助都将不胜感激
解决问题的最简单的方法是用您真正需要的WSGIRequest/HttpRequest片段创建一个字典
假设您的WSGIRequest包含“用户名”和“电子邮件”部分。然后将索引重构为如下内容:
如果您知道这是一种post方法,那么最快的测试是
免责声明:我从未使用过Django或任何其他web框架,但我对芹菜知之甚少
相关问题 更多 >
编程相关推荐