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 929411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:10:01+00:00 2026-05-15T20:10:01+00:00

In my main page I have included a template with form for adding emails

  • 0

In my main page I have included a template with form for adding emails to newsletter. I’d like this form to add new emails without redirecting anywhere. How I can achieve that ? Here is my code, when I was using separate page for this :

views :

def newsletter_add(request):
    if request.POST:
        f = NewsletterForm(request.POST)
        if f.is_valid():
            try:
                e = NewsletterEmails.objects.get(email = request.POST['email'])
                msg = u'Mail already added'
                return render_to_response('newsletter/add.html',
                    {'form':f,'msg':msg,},RequestContext(request))
            except Address.DoesNotExist:
                e = NewsletterEmails(email = request.POST['email'])
                e.save()
                msg = u'Mail added'
                return HttpResponseRedirect('/')
    else:
        f = NewsletterForm()
    return render_to_response('newsletter/add.html',{'form':f,},RequestContext(request))

form :

{% block content %}
    <div class="center-right">
        <div class="pane profile">
            <div class="div-content">
                {{ msg }}
                <form action="" method="post" enctype="multipart/form-data">
                    {{form.as_p}}
                    <input type="submit" class="submit" name="submit" value="Ok" />
                </form>
            </div>
        </div>
    </div>
{% endblock %}

forms :

class NewsletterEmails(forms.Form):
    email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,maxlength=75)),label=_("email"))
  • 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-15T20:10:02+00:00Added an answer on May 15, 2026 at 8:10 pm

    without redirecting anywhere means

    1. the form submission should not redirect (or)
    2. after submitting the form user should be redirected to the same page with the form.

    in case-1 you can do this using jquery-ajax-forms

    in case-2 after the post request redirect the user to the same page instead of redirecting to ‘/’

    return HttpResponseRedirect('redirect/to/form/page')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main page that I want to be a sort of dispatch
I am looking for a CSS-based web page template where the main content div
Our SEO team would like to open up our main dynamic search results page
I've made a change to what I thought was the main default template page
In my main page (call it index.aspx ) I call <%Html.RenderPartial(_PowerSearch, ViewData.Model);%> Here the
I need to create a cherrypy main page that has a login area. I
I want a hyperlink on my main page to launch an HTML help page
I am building a relatively simple Django application and apart from the main page
My main JavaScript framework is jQuery , so I would like my unit test
I have made a helper class called Navigation that gets used on every page

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.