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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:15:19+00:00 2026-06-02T08:15:19+00:00

Below there is my code. I don’t know how to redirect back after some

  • 0

Below there is my code. I don’t know how to redirect back after some validation errors
Urls.py:

    (r'^comments/', include('django.contrib.comments.urls')),

views.py:

def show_episode(request, episode) :
episode = get_object_or_404(Episode, pk=episode)

return render_to_response('episode.html', context_instance=RequestContext(request, {
    'episode' : episode,
    }))

episode.html:

        <div class="subsection">
        {% get_comment_form for episode as form %}
        <table>
            <form action="{% comment_form_target %}" method="post">
                {% csrf_token %}
                {{ form }}
                <tr>
                    <td colspan="2" style="text-align: center">
                        <input type="submit" name="submit" value="Post">
                        <input type="submit" name="preview" value="Preview">
                    </td>
                </tr>
                <input type="hidden" name="next" value="{% url episode episode.id %}" />
            </form>
        </table>
    </div>
    <div class="subsection">{% render_comment_list for episode %}</div>

I want to come back to this form when there will be some errors.


I try, but I have an error: ‘QueryDict’ object has no attribute ‘_meta’
Code:

def comments(request) :
if request.method == 'POST' :
    form = CommentForm(request.POST)
    if (form.is_valid()) :
        form.save()
    return HttpResponseRedirect(request.POST['next'])
return HttpResponseRedirect('/')
  • 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-06-02T08:15:20+00:00Added an answer on June 2, 2026 at 8:15 am

    Do it the other way around: process the form in the same view (that is, set <form action="", this way the user won’t lose his inputs (as he would with a redirect).

    You can still call the other view via this view, though. ( if request.method == 'POST')

    When there was no Error, send a response.redirect to a success view.

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

Sidebar

Related Questions

Below is my code (don't worry there's a USUW at the top of the
i want to know is there any groovier way of code below: def dataList
The below code works when there are a few element in the To list
in the code below at first if statements block (there will be more than
In my code below, is there any way I can use the results in
Is there a way to get the code below to return null if no
I have below code to insert a style into DOM (there is a use
With the following code below, There is an error saying File /home/user/web_pro/info/views.py, line 184,
For the below code, there ia a form in the location /home/form.php .How can
The code below is resulting in an error on a site in which there

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.