1234567891011121314151617181920 |
- def notice_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 = 7
- 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 = 7
- file_save.file = request.FILES.get("file")
- file_save.save()
- return redirect('notice_view')
- return render(request, 'notice_write.html')
|