本文整理汇总了Python中forms.MessageForm.data["content"]方法的典型用法代码示例。如果您正苦于以下问题:Python MessageForm.data["content"]方法的具体用法?Python MessageForm.data["content"]怎么用?Python MessageForm.data["content"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.MessageForm
的用法示例。
在下文中一共展示了MessageForm.data["content"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: thread
# 需要导入模块: from forms import MessageForm [as 别名]
# 或者: from forms.MessageForm import data["content"] [as 别名]
def thread(request, **args):
t = loader.get_template("discussion.view")
thread = None
if "id" in args:
thread = Thread.objects.get(id=int(args["id"]))
message_form = None
if thread and thread.openForEvent():
if request.method == "POST":
# Post dictionary needs to be mutable in order to remove the value from the messagebox
post_vars = {}
for key in request.POST:
post_vars[key] = request.POST[key]
message_form = MessageForm(post_vars)
if message_form.is_valid():
message = Message()
message.content = message_form.cleaned_data["content"]
message_form.data["content"] = ""
message.time = datetime.now()
message.user = request.user
message.thread = thread
message.save()
else:
message_form = MessageForm()
c = {
"thread": thread,
"thread_message": thread.getStatusMessage(),
"thread_status": thread.getStatus(),
"messages": None,
"message_form": message_form,
"is_authenticated": request.user.is_authenticated(),
}
if thread:
messages = Message.objects.filter(thread__id=thread.id)
c["messages"] = messages
c.update(csrf(request))
return HttpResponse(t.render(Context(c)))