1๐
โ
If your view is intended to create a ProjectFile
, I would recommend you use a CreateView
, and override the form_valid
method.
from django.views.generic import CreateView
class UploadFileView(CreateView):
form_class = FileUploadForm
template_name = 'project/file_upload.html'
def form_valid(self, form):
form.instance.user = self.request.user
return super(UploadFileView, self).form_valid(form)
You could still override the same method even if you wish to use the FormView
.
๐คmeshy
Source:stackexchange.com