def _warning_if_username_changed(self, form): new_username = form.cleaned_data['username'] old_username = form.initial['username'] if new_username != old_username: message = _( "Warning : your username has been changed. Next time you log in to our site, use <b>'{}'</b> " "(the new one) instead of <s>'{}'</s> (the old one)").format( new_username, old_username) add_message(self.request, messages.WARNING, message)
def form_valid(self, form): add_message(self.request, messages.SUCCESS, _('Profile data successfully updated.')) self._warning_if_username_changed(form) return super().form_valid(form)
def get_success_url(self): add_message(self.request, messages.SUCCESS, _('Form successfully submitted.')) return reverse('accounts:login')
def form_valid(self, form): add_message(self.request, messages.SUCCESS, _('Password successfully updated.')) return super().form_valid(form)
def render_to_response(self, context, **response_kwargs): add_message(self.request, messages.SUCCESS, _('Successfully logged out.')) return HttpResponseRedirect(reverse('home'))