views.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:steemprojects.com 作者: noisy 项目源码 文件源码
def edit_timeline(request, slug, template_name="package/timeline_form.html"):
    project = get_object_or_404(Project, slug=slug)
    if not request.user.profile.can_edit_package(project):
        return HttpResponseForbidden("permission denied")

    if request.POST:
        formset = TimelineEventFormSet(data=request.POST, project=project,)
    else:
        formset = TimelineEventFormSet(project=project, queryset=TimelineEvent.objects.filter(project=project))

    if formset.is_valid():
        formset.save()

        messages.add_message(request, messages.INFO, 'Project updated successfully')
        return HttpResponseRedirect(reverse("package", kwargs={"slug": project.slug}))

    return render(request, template_name, {
        "formset": formset,
        "package": project,
        "action": "Save",
    })
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号