📜  传递用户实例 django 表单提交 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.195000             🧑  作者: Mango

代码示例1
if form.is_valid():
    post = form.save(commit=False)
    post.author = request.user
    post.published_date = timezone.now()
    post.save()