我试图实现一个继承表单FormView的类视图。我的问题是我需要将request.user添加到我尝试过的ContactUploadForm :
ContactUploadForm(request.user) and ContactUploadForm(self.request.user)
但是,我如何获得请求?我不明白这些将如何工作。
class ImportFromFile(FormView):
"""
Class view import that allows a user to upload a single file (CSV, Excel) of contacts to a group.
Inherits :FormView: - A view for displaying a form, and rendering a template response.
"""
template_name = 'contacts/import_file.html'
form_class = ContactUploadForm(request.user)