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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:03:04+00:00 2026-06-17T00:03:04+00:00

i have successfully set the app to send me to url like http://localhost:8000/log_in/?next=/task/1/ i

  • 0

i have successfully set the app to send me to url like

http://localhost:8000/log_in/?next=/task/1/

i have defined the context processors as following

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",
    "django.core.context_processors.request",

)

but when i login it redirects me instead to the home page, i printed the request in my login view and i got the GET is empty query set which is strande, any ideas why !?

i also tried adding

<input type="hidden" name="next" value="{{next}}" />

to the login.html, but this added the next to the POST request as an empty parameter

Edit 1
The login view, and i try to print the ‘next’ parameter and it returns null, because the the GET is an empty queryset

def log_in(request):
    """
    This method checks for the input username(email) and password.
    If they are empty the user id redirected to the login page, else checks whether
    the user is authenticated. If the user is not found in the database, it renders the login
    page with an error_message that the email or password are invalid. Further, it checks if the user's
    account is activated, it not he is redirected back to login and notified.
    If the user is activated, it checks for the field remember_me, if it is not checked, then the
    expiry date of the session is set to when the browser is closed.
    Then the user is logged in using the login in django backends and it checks on the session
    value if it is his first time or not to open the getstrated instead of the normal profile.
    """
    print request.GET['next']
    base_login=True
    if request.POST.has_key('username') and request.POST.has_key('password'):
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        if user is None:
            error_message = "The Email/Password is incorrect."
            return render(request, 'userprofiles/registration.html', {'error_message': error_message})
        else:
            if user.is_active:
                if not request.POST.get('remember_me', False):
                    request.session.set_expiry(0)

                login(request, user)

                request.session['DEPLOYED_ADDRESS'] = settings.DEPLOYED_ADDRESS

                first_week = False
                logged_user = UserProfile.objects.get(username=request.user.username)
                if (((request.user.last_login - request.user.date_joined).days) < 8) and (logged_user.got_started == False):
                    first_week = True

                if first_week:
                    return redirect('/getting_started/', RequestContext(request))
                else:
                    return redirect('/', RequestContext(request))

            else:
                error_message = "This Email Hasn't Been Activated Yet. Please Check The Activation Mail Sent To You."
                return render(request, 'userprofiles/registration.html', {'error_message': error_message})
    else:
        RegistrationForm = get_form_class(up_settings.REGISTRATION_FORM)

        if request.method == 'POST':
            form = RegistrationForm(data=request.POST, files=request.FILES)

            if form.is_valid():
                new_user = form.save()
                username = form.cleaned_data['username']
                password = form.cleaned_data['password']

                request.session['login'] = "first"



                # Automatically log this user in
                if up_settings.AUTO_LOGIN:

                    if up_settings.EMAIL_ONLY:
                        username = form.cleaned_data['email']

                    user = authenticate(username=username, password=password)
                    if user is not None:
                        if user.is_active:
                            login(request, user)
                            calculate_profile_completion(request)


                return redirect(up_settings.REGISTRATION_REDIRECT)

        else:
            form = RegistrationForm()


        return render(request, 'userprofiles/registration.html', {'form': form,'base_login': base_login})
  • 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-17T00:03:05+00:00Added an answer on June 17, 2026 at 12:03 am

    When you want to render the form, the browser makes a GET request to your Django app (this has nothing to do with request.GET and request.POST, which merely contain data sent as URL parameters or form-encoded data respectively, and are always available). Since you are using the next URL parameter during the GET request, you will have access to it then. However, you then proceed to render the form page as a response to the request without including next anywhere, so browser no longer has access to this value, nor does your app.

    When the browser then proceeds to submit the form, it does so by performing a POST request. It so happens that you are using the same handler to handle this request, but it is still a separate request, and therefore, next, which you are not passing through the form or URL parameter, is lost.

    You can fix this in the original GET request (before showing the form to the user). As soon as you receive the next URL parameter, you can do one of the following:

    Put it in the login form by passing the value to the template via context, and rendering a hidden field within the form:

    <!-- inside your FORM element -->
    <input type="hidden" name="next" value="{{ next }}">
    

    Putting next in session during GET request:

    request.session['next'] = request.GET.get('next', '/')
    

    There are more methods (e.g., adding hidden field in the login form class), but the above two are most straightforward.

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

Sidebar

Related Questions

I need to set alarm in google calendar via Android app. I have successfully
I'm trying to integrate Twitter with my App right now. I have successfully set
I have successfully pushed one app code onto github. I had set up the
I have successfully set up FILESTREAM on my SQL 2008 server; however I've noticed
I have successfully set up an HgWebDir instance over CGI with Apache, and I
I'm using the the new UIAppearance API and have successfully set the tint color
I have not found any way to successfully set a screen resolution on my
I have successfully implemented this from android to a java httpservlet on google app
I have Facebook connect set up for my iphone app and am able to
I have an app that allows the user to send a test email from

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.