def test_write(request): if request.method == 'POST': form = ContentForm(request.POST) form_file = FileForm(request.POST, request.FILES) if form.is_valid(): question = form.save(commit=False) question.author = request.user question.create_date = timezone.now() question.boardname_id = 14 question.save() if form_file.is_valid(): form_file = FileForm(request.POST, request.FILES) file_save = form_file.save(commit=False) file_save.author = request.user file_save.postcontent = question file_save.boardname_id = 14 file_save.file = request.FILES.get("file") file_save.save() return redirect('test_list') return render(request, 'test_write.html')