-1
我是Python/Django中的新手,我试图实现Django活动流,并且我有点卡住了。如何在我们刚刚创建的对象上使用object.get()
这里是我的代码:
if request.method == 'POST':
title = request.POST.get('title', '')
content = request.POST.get('text', '')
author = request.POST.get('author', '')
now = timezone.now()
post_article = Article.objects.create(
article_title=title,
article_content=content,
pub_date=now,
author=author)
article = ?
action.send(request.user, verb='posted article', action_object=post_article, target=article)
正如你所看到的,用户创建的POST方法的文章,我想新创建文章的标题,并在其设置为目标我的活动流,但我不知道如何去做。
任何帮助将是伟大的。
'post_article.article_title'? – jonrsharpe
请务必阅读本教程。 Django具有验证用户输入所需的所有工具,**。不。保存。提交。数据。没有。证实。它**。永远。使用表单API或DRF,这就是他们的用途。 – spectras
我刚刚进入它,所以任何建议将被接受,谢谢 – Farel