所以我有这个代码:
post = request.POST.copy()
post['relationshipId'] = theRelationship.id
theStory = StoryForm(post, request = request, initial {'relationshipId' : theRelationship.id})
最初,我的代码如下所示:
theStory = StoryForm(request.POST, request = request, initial {'relationshipId' : theRelationship.id})
这导致了验证问题。验证器会抱怨没有设置 relationshipId。为什么会这样?
编辑:第一段代码运行良好,我对此非常满意。问题与第二个代码块有关,它最初是我所拥有的(以及我刚刚花了一些时间处理的),对我来说,它表现得“奇怪”