def form_invalid(self, form): if self.request.is_ajax(): return render_to_json_response({ 'status': 'validation failed', 'errors': form.errors }) else: return super(ProfileSettingsView, self).form_invalid(form)
def form_valid(self, form): SUCCESS_MESSAGE = 'Your profile was updated successfully.' if self.request.is_ajax(): return render_to_json_response({ 'status': 'ok', 'message': SUCCESS_MESSAGE }) else: messages.success(self.request, SUCCESS_MESSAGE) return super(ProfileSettingsView, self).form_valid(form)