Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7000197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:38:24+00:00 2026-05-27T20:38:24+00:00

I am attempting to create a page where a user can see what their

  • 0

I am attempting to create a page where a user can see what their current email is and change it if they would like. I am just testing with a very simple form and a very simple HttpResponseRedirect if the form is not valid. However neither my email is changing for the user nor is my failure response if the form is not valid working. I am not sure what is causing this

forms.py:

    class ChangeEmail(forms.Form):
        email1 = forms.EmailField(label=u'Type new Email')
        email2 = forms.EmailField(label=u'Type Email again') 

views.py:

def change_email(request, username):
    if request.method == 'POST':
        user1 = User.objects.get(username=username)
        form1 = ChangeEmail(request.POST)
        if form1.is_valid():
            user1.email = form.cleaned_data['email1']
            form1.save()
            return HttpResponseRedirect('/register/success')
        else:
            return HttpResponseRedirect('/stupid')
    else:
        user = User.objects.get(username=username)
        email = user.email
        form = ChangeEmail()
        variables = RequestContext(request, {
            'form': form,
            'email': email
        })
        return render_to_response('registration/email.html', variables

Thanks for your help in advance.

EDIT:

The URL that I have mapped to render the form is /user/testuser/email. I am attempting to put in invalid input in to the fields to get an error message but when I push submit it redirects me back to /user/testuser page which displays info about the user. My change email template is below:

{% extends "base.html" %}
{% block title %}Change Email{% endblock %}
{% block head %}Change Email{% endblock %}
{% block content %}
<p> Current Email: {{ email }} </p>
<form method="post" action=".">{% csrf_token %}
  {{ form.as_p }}
  <input type="submit" value="Change Email" />
</form>
{% endblock %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:38:25+00:00Added an answer on May 27, 2026 at 8:38 pm

    ChangeEmail is a normal form. These don’t have save methods – only ModelForms do. You’re correctly setting the user email from the form’s cleaned_data – but you should be saving the user1 object, not the form.

    Also, it’s best not to redirect away on validation failure. Leave out that first else clause, and move the variables/render_to_response lines back one indentation level, and the form will be redisplayed with any errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a web page that will allow a user to
I'm attempting to create an anti-bruteforcer for the login page on a website. Unfortunately,
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I am attempting to create a hyperlink from an existing url that I would
I am attempting to allow a user to type in their search query in
I am attempting to create a profile page that shows the amount of dwarves
I'm attempting to use JQuery to create a dynamic page header using an image
Im attempting to create a new operator :? on lists, which operates the same
I attempting to create an 800x500 div with four overlapping divs inside the container
I attempting to create custom tabs using this . But when I try to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.