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()
python类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(WorkSettingsView, 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(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(SettingsView, 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)