Hi, There are 2 errors in your code.
First, when you do a request to the page, it is a get (you go from another page to this page). In this case the next parameter is there and you receive it in the "else" part of your view function (because the request is a get). So you have the next parameter as a get parameter in that case. Second, when you submit the form, it is submitted via a post. In this case the get parameters are filled out, but the POST part of the request is. So you populate your form with the information sent via a POST, and you do this here: form = pollster.forms.LogInForm(request.POST) So the GET part of the request is empty in this case, because the request is a POST. What you need to do is get the parameter from the request when you populate the form and then send it to the template: def log_in(request): if request.method == "POST": form = pollster.forms.LogInForm(request.POST) if form.is_valid(): username = form.cleaned_data["username"].lower() password = form.cleaned_data["password"] next = form.cleaned_data('next') reply = django.shortcuts.redirect(next) user = AUTH(username = username, password = password) if user: django.contrib.auth.login(request, user) else: reply = django.shortcuts.render(request, "log_in.html", {"form" : form}) else: form = pollster.forms.LogInForm(initial_data={'next': request.GET.get('next')}) reply = django.shortcuts.render(request, "log_in.html", {"form" : form}) return reply So I have updated the code both for the get and post. The get populates the initial data for the form (the next parameter). You of course need to add the next field to your form code. Then in the template you can add the following: <div id = "log_in"> <form action = "." method = "post"> <input type="hidden" name="next" value="{{form.next.value}}"> <p>Username:</p> <p>{{form.username}}</p> <p>Password:</p> <p>{{form.password}}</p> <p><input type = "submit" value = "Submit"/></p> {% csrf_token %} </form> </div> This way your form will include the posted next data and you can get the next field from the login form. Regards, Andréas Den fre 1 nov. 2019 kl 19:10 skrev Christian Seberino <cseber...@gmail.com>: > I can see the next parameter hanging off the URL of my log_in page. > However, I cannot *read* it in my view code. The next parameter does NOT > get > passed to my Python code...Why not? Is my form action = "." the problem > below? > > Here is the traceback..... > > https://dpaste.de/H7KU > > Here is my log in page... > > > def log_in(request): > if request.method == "POST": > form = pollster.forms.LogInForm(request.POST) > if form.is_valid(): > username = form.cleaned_data["username"].lower() > password = form.cleaned_data["password"] > next = request.GET.get("next") > reply = django.shortcuts.redirect(next) > user = AUTH(username = username, > password = password) > if user: > django.contrib.auth.login(request, user) > else: > reply = django.shortcuts.render(request, > "log_in.html", > {"form" : form}) > else: > form = pollster.forms.LogInForm() > reply = django.shortcuts.render(request, > "log_in.html", > {"form" : form}) > > return reply > > Here is my template... > > <!DOCTYPE html> > <html> > <head> > <title>Pollster</title> > <link type = "text/css" > href = "/static/base.css" > rel = "stylesheet"> > <meta content = "text/html; charset=utf-8" > http-equiv = "content-type"> > </head> > <body> > > <div id = "log_in"> > <form action = "." method = "post"> > <p>Username:</p> > > <p>{{form.username}}</p> > > <p>Password:</p> > > <p>{{form.password}}</p> > > <p><input type = "submit" value = "Submit"/></p> > > {% csrf_token %} > </form> > </div> > > </body> > </html> > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/bed8ec66-572d-4306-a496-edf9b69142bb%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/bed8ec66-572d-4306-a496-edf9b69142bb%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCfS_kCPSzZ%3DNMhcFR8uBK%2Bo7bta-MkL-U%3D7m4DM%2B5s2Fw%40mail.gmail.com.