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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:48:25+00:00 2026-06-11T07:48:25+00:00

Hy there, i just read here that posted data can’t be sent by a

  • 0

Hy there,

i just read here that posted data can’t be sent by a redirect,

and then found that people are generally not happy with using redirects. And my question is why?


My situation

I have a Django app which starts by rendering a page which gives the choice of using Registered or Anonymous usage.

def start(request):
    request.session.flush()
    return render_to_response('start.html')

If Registered usage is chosen a simple form is rendered to insert the registration data, and it loops to itself until form is valid after which ‘auth/’ takes place.

def registration(request):
if request.method == "POST":
    form = RegistrationForm(request.POST)
    if form.is_valid():
        return HttpResponseRedirect('auth/')
    else:
        return render_to_response('registration.html',
                                 {'form':form})
form = RegistrationForm()
return render_to_response('registration.html',
                         {'form':form})

If anonymous usage is chosen, the registration page is skipped, and is redirected to ‘auth/’, the same Django view function like in upper code:

return HttpResponseRedirect('auth/')

What i was hoping to achieve with auth is for it to just set the sessions, write the data to a database and then redirect the next page which is identical to Registered and Anonymous users (only the sessions would differ).

def auth(request):
    ipdb.set_trace()
    if request.method == "POST":
        request.session['user_type'] = 'REG'
        request.session['email'] = request.POST['email']
        request.session['first_name'] = request.POST['first_name']
        RegisteredUser.objects.create(first_name = request.POST['first_name'],
                                      email = request.POST['email'],
                                      company = request.POST['company'])
    else:
        request.session['user_type'] = 'ANONIM'
    return HttpResponseRedirect('next_page')

Of course, when the debugger starts, request.method always returns GET.


My reasons

There is a lots of talking about separating the view from the logic, and i don’t find it very readable or loosely coupled when i have a Django view function (if I drop the ‘auth/’, ‘next_page’ would have to take it’s functionality) which has to

  • Check for request.post

    • If there if the reason for it is form validation of the current page, or if it’s from the previous page, in which case write that data to a base
  • Do additional checks to set the sessions for registered or anonymous user

which I would have to do since using separated functions just for logic that redirects instead of rendering doesn’t seem as the generally accepted way.

Can someone please shed some light on things?

UPDATE WITH SOLUTION

Thanks to the answers i figured out the pattern on how to do this. The code for registration is now:

def registration(request):
    if request.method == "POST":
        form = RegistrationForm(request.POST)
        if form.is_valid():
            request.session['user_type'] = 'REG'
            request.session['email'] = request.POST['email']
            request.session['first_name'] = request.POST['first_name']
            RegisteredUser.objects.create(first_name = request.POST['first_name'],
                                          email = request.POST['email'],
                                          company = request.POST['company'])

            return HttpResponseRedirect('param_select/')
        else:
            return render_to_response('registration.html',
                                     {'form':form},
                                     context_instance = RequestContext(request))
    form = RegistrationForm()
    return render_to_response('registration.html',
                             {'form':form},
                             context_instance = RequestContext(request))

From now on, I’m using the “Loop into yourself with POST data, and then perform the logic” method.

To demystify the name, thats what the new registration(request) does.

First it renders the form to input the data

Than it is recalled once the data is submitted because of link to itself

form action="" method="post"

This is repeated until correct form data isn’t submitted after which the logic is called (in this case, writing to a base and setting the sessions).

It ends with a httpRedirect to a different page leaving the registration completely handled by registration(request).

  • 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-11T07:48:26+00:00Added an answer on June 11, 2026 at 7:48 am
    • By default you can assume that user is anonymous and set request.session['user_type'] = 'ANONIM' in your start() view.

    • Whatever you are doing in auth() you can do it in registration() along with request.session['user_type'] = 'REG'. With this you can use the validated form to create RegisteredUser and flag errors as well if required.

    • And once POST processing is valid and complete it can redirect to your next_page.

    • If anonymous user is chosen, start will redirect to next_page rather than auth/

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

Sidebar

Related Questions

I've read through many threads and can't find anything like my issue here. I
I am learning about smart pointers ( std::auto_ptr ) and just read here and
I have read here: Is there a way to use a Custom cross-sectional slicer
I was reading about linux kernel development and I just read some text that
was wondering if there are anyone else here that has signed up with the
Say that I have the Python code: someString = file(filename.jpg).read() How can I replicate
I know that there are a variety of similarly posed questions here on SO
Hi there just wondering; How do I deny direct access to files in a
There are just two forms i knew to retrieve resource values in xml files:
sorry for the stupid questions but there are just some things about WCF I

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.