You need to pass the instance created by the form, rather than just the form class. For example:
FileModel.objects.create(post=form.instance, file=f)
Update: As the Article hasn't been saved yet, when you try to attach it to the FileModel object, it won't let you.
Try something like this:
def form_valid(self, form):
post = form.save(commit=False)
post.author = self.request.user
post.save()
for f in self.request.FILES.getlist('file'):
FileModel.objects.create(post=post, file=f)
return redirect('/')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…