S
S
sergey199408082017-05-13 09:22:08
Django
sergey19940808, 2017-05-13 09:22:08

Django how to change email address?

Good afternoon, how to implement a change in the email address, without sending a confirmation, just change it in the database to the old one?
Here is the view code:

@login_required()
    def email_change(request, user_id):
        title = 'Смена электронного адреса'
        user = get_object_or_404(User, id=user_id)

        if request.method != 'POST':
            form = ChangeEmail()

        else:
            form = ChangeEmail(request.POST)

            if form.is_valid():
                user.email = form.cleaned_data['email']
                user.save()

            return HttpResponseRedirect(reverse('users:user', user.id))

        context = {'title': title, 'user': user, 'form': form}
        return render(request, 'users/email_change_form.html', context)

When trying to change the email address, an error occurs - "'ru-RU' is not a registered namespace"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Burnaev, 2017-05-13
@sergey19940808

It seems that this error occurs at the time of rendering or preparing the page to which you are redirecting .... Look carefully at the template and the view for the occurrence of 'ru-Ru'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question