我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.views.generic.edit.FormView()。
def get_form_class(self): # @@@ django: this is a workaround to not having a dedicated method # to initialize self with a request in a known good state (of course # this only works with a FormView) self.primary_email_address = EmailAddress.objects.get_primary(self.request.user) return super(SettingsView, self).get_form_class()
def get_form_class(self): # @@@ django: this is a workaround to not having a dedicated method # to initialize self with a request in a known good state (of course # this only works with a FormView) self.primary_email_address = EmailAddress.objects.get_primary(self.request.user) return super(WorkSettingsView, self).get_form_class()
def form_valid(self, form): if form.is_valid(): obj = form.save(commit=False) obj.user = self.request.user obj.save() messages.add_message(self.request, messages.INFO, 'Request successfully made.') return super(FormView, self).form_valid(form)